beanhead0321
New Member
- Joined
- Jul 8, 2011
- Messages
- 14
Hey Guys,
I'm trying to update a PivotTable with the range selected in the inputbox (from another workbook), but I can't seem to get it to work. I don't know very much VBA and have just been putting pieces together so my code might be totally incoherent. Thanks in advance!
I'm trying to update a PivotTable with the range selected in the inputbox (from another workbook), but I can't seem to get it to work. I don't know very much VBA and have just been putting pieces together so my code might be totally incoherent. Thanks in advance!
Code:
Private Sub CommandButton1_Click()
Dim SmartData As Range
On Error Resume Next
Set SmartData = Application.InputBox(prompt:="Select Data", Type:=8)
With SmartData
.Parent.Parent.Activate
.Parent.Activate
.Select
End With
'Selects SmartData Range for update
ActiveSheet.PivotTables("PivotTable3").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
SmartData.Address, _
Version:=xlPivotTableVersion12)
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
End Sub