VBAProIWish
Well-known Member
- Joined
- Jul 6, 2009
- Messages
- 1,027
- Office Version
- 365
- Platform
- Windows
Hello All,
I recorded the code below and after literally 3 hours of trying to turn the recorded code into dynamic code, I finally gave up!
Can anyone get this recorded code to work dynamically by selecting the current region?
Note that below shows both recorded code and my best attempt at dynamic code...
I recorded the code below and after literally 3 hours of trying to turn the recorded code into dynamic code, I finally gave up!
Can anyone get this recorded code to work dynamically by selecting the current region?
Note that below shows both recorded code and my best attempt at dynamic code...
VBA Code:
'RECORDED CODE
ActiveSheet.ChartObjects("Chart 1").Activate
Application.CutCopyMode = False
ActiveSheet.PivotTables("PivotTable2").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, _
SourceData:="MSDB!R1C1:R100C18", Version:=6)
'END RECORDED CODE
'MY BEST ATTEMPT AT DYNAMIC CODE
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.PivotTables("PivotTable2").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, _
SourceData:=Worksheets("MSDB").Range("A1").CurrentRegion.Address)
'END MY BEST ATTEMPT AT DYNAMIC CODE