Challenge

Project 2 - Create a report using PowerQuery, Macro VBA, List Functions and Data Validation functions for Data Reporting of Supply Chain Management companies

Step 1: Data Preparation

2.Step 2: Create Pivot Tables

Sub CreateGenderRatioPivot()

    Dim ws As Worksheet

    Set ws = ThisWorkbook.Worksheets.Add

    ws.Name = "GenderRatio"

    ' Assuming your data is on a sheet named "Data"

    Dim dataSheet As Worksheet

    Set dataSheet = ThisWorkbook.Sheets("Data")

    ' Define the pivot table range

    Dim ptRange As Range

    Set ptRange = dataSheet.Range("A1").CurrentRegion

    ' Create the pivot table

    Dim pivotTable As PivotTable

    Set pivotTable = ws.PivotTableWizard(TableDestination:=ws.Cells(3, 1), _

        SourceType:=xlDatabase, SourceData:=ptRange)

    ' Add Gender to Rows and Count of Gender to Values

    With pivotTable.PivotFields("Gender")

        .Orientation = xlRowField

        .Position = 1

    End With

    pivotTable.AddDataField pivotTable.PivotFields("Gender"), "Count of Gender", xlCount

End Sub

2.Step 3: Create Pivot Charts

Sub CreateGenderRatioPivot()

    Dim ws As Worksheet

    Set ws = ThisWorkbook.Worksheets.Add

    ws.Name = "GenderRatio"

    ' Assuming your data is on a sheet named "Data"

    Dim dataSheet As Worksheet

    Set dataSheet = ThisWorkbook.Sheets("Data")

    ' Define the pivot table range

    Dim ptRange As Range

    Set ptRange = dataSheet.Range("A1").CurrentRegion

    ' Create the pivot table

    Dim pivotTable As PivotTable

    Set pivotTable = ws.PivotTableWizard(TableDestination:=ws.Cells(3, 1), _

        SourceType:=xlDatabase, SourceData:=ptRange)

    ' Add Gender to Rows and Count of Gender to Values

    With pivotTable.PivotFields("Gender")

        .Orientation = xlRowField

        .Position = 1

    End With

    pivotTable.AddDataField pivotTable.PivotFields("Gender"), "Count of Gender", xlCount

End Sub

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.