How do I write a macro that will select all sheets containing the test "-DR"? Hopefully someone can also tell me how to select all pivot tables in those sheets once I've done this...
This will do something to each sheet ending in "DR". What you want to do is up to you, but note that you generally don't need to select objects in order to work with them.
Thanks, but I'm fairly inept with Excel, and here's what I've tried to do: the formula runs without any errors, but it isn't working. I'm trying to select all pivot tables on the worksheets containing "-DR" in the title and reset their data range to the entire "Database" worksheet. Here's the code I tried to insert:
Code:
Sub Update()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If Right(ws.Name, 2) = "DR" Then Activate.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"'Direct Database'!R1C1:R60000C150"
Next ws
End Sub
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.