Project 2 - Create a report using PowerQuery, Macro VBA, List Functions and Data Validation functions for Data Reporting of Supply Chain Management companies
Sub CreateGenderRatioChart()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("YourDataSheet")
Dim pt As PivotTable
Dim pc As PivotChart
' Create a PivotTable
Set pt = ws.PivotTableWizard(TableName:="PivotTable_GenderRatio", SourceType:=xlDatabase, SourceData:=ws.UsedRange)
' Add fields to the PivotTable
With pt.PivotFields("Gender")
.Orientation = xlRowField
.Position = 1
End With
pt.AddDataField pt.PivotFields("Applicant ID"), "Count of Applicants", xlCount
' Create a PivotChart
Set pc = ws.Shapes.AddChart2(251, xlColumnClustered).Chart
pc.SetSourceData Source:=pt.TableRange1
End Sub
Sub FlagColumnSummary()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("YourDataSheet")
Dim CriteriaRange As Range
Dim FlagCount As Long
' Define the criteria range and count
Set CriteriaRange = ws.Range("B2:B100") ' Example range
FlagCount = Application.WorksheetFunction.DCount(ws.UsedRange, "FLAG_DOCUMENT_2", CriteriaRange)
' Output the count
MsgBox "Count of FLAG_DOCUMENT_2: " & FlagCount
End Sub