Hi everyone - I currently have a macro where I loop through a range of cells to select items in a pivot table. My problem is if I mistype or fat finger an entry in my range, it overwrites whatever pivot item is in the pivot table and gives me mislabled and usually inaccurate data.
My question is, is it possible to tell my macro to return an error/stop running rather than overwrite the pivot item?
I've searched for this extensively and have been unable to find so I may just need to figure something else out, but figured I'd ask myself to see if anybody might have an idea.
I'm using excel 2007. Here is an general example of the current coding:
Thanks as always-
Joe
My question is, is it possible to tell my macro to return an error/stop running rather than overwrite the pivot item?
I've searched for this extensively and have been unable to find so I may just need to figure something else out, but figured I'd ask myself to see if anybody might have an idea.
I'm using excel 2007. Here is an general example of the current coding:
'VARIABLES AND LABELS
Dim pt As PivotTable
dim report as long
Set pt = Sheets("Pivot Sheet").PivotTables(1)
Dim rangename1 As String
Dim rangename2 As String
'PIVOT TABLE SELECTIONS
Dim queryct As String
Sheets("Range Sheet").Select
queryct = Application.WorksheetFunction.CountA(Range("A:A"))
For report = 2 To queryct Step 1
rangename1 = Sheets("Range Sheet").Cells(report, 4) & ""
rangename2 = Sheets("Range Sheet").Cells(report, 5) & ""
pt.PivotFields("Pivot Item 1").CurrentPage = rangename1
pt.PivotFields("Pivot Item 2").CurrentPage = rangename2
Thanks as always-
Joe
Last edited: