Skip to content

Instantly share code, notes, and snippets.

@github-shakti
Last active September 10, 2017 22:15
Show Gist options
  • Select an option

  • Save github-shakti/d721ab6774d2f0f1a3f9f3e8dce4f500 to your computer and use it in GitHub Desktop.

Select an option

Save github-shakti/d721ab6774d2f0f1a3f9f3e8dce4f500 to your computer and use it in GitHub Desktop.
IDSP Excel Macro
Sub MacroIDSP()
'
' MacroIDSP Macro
'
'
On Error Resume Next
Columns("C").SpecialCells(xlBlanks).EntireRow.Delete
Range("E1:E200").Select
Selection.NumberFormat = "0"
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R127C5", Version:=6).CreatePivotTable TableDestination:= _
"", TableName:="PivotTable1", DefaultVersion:=6
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
With ActiveChart.PivotLayout.PivotTable.PivotFields("IDSP Code")
.Orientation = xlRowField
.Position = 1
End With
With ActiveChart.PivotLayout.PivotTable.PivotFields("User Name")
.Orientation = xlRowField
.Position = 2
End With
With ActiveChart.PivotLayout.PivotTable.PivotFields("EHR ID")
.Orientation = xlRowField
.Position = 3
End With
ActiveChart.PivotLayout.PivotTable.AddDataField ActiveChart.PivotLayout. _
PivotTable.PivotFields("EHR ID"), "Count of EHR ID", xlCount
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment