Thread: universal code
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lou Sanderson Lou Sanderson is offline
external usenet poster
 
Posts: 26
Default universal code

I used the record macro so I can programatically re-run getting external data
into a pivot table after clearing and deleting all the cells. The macro
recorded explicitly to the workbook I was working in while recording. I'd
like help with making my code more universal. How should I modify the
following code to allow it to run on different workbooks?

..CreatePivotTable TableDestination:=" ' [Workbook Name.xls] Query Name ' !
R5C1", _
TableName:="PivotTable5", DefaultVersion:=xlPivotTableVersion10

and

ActiveWindow.Visible = False
Windows("Workbook Name.xls").Activate
Range ("A2").Select

Thanks,
Lou Sanderson