Basic Error Checking in Excel VB

R

RestlessAde

Hi,

I'm running the code:

ActiveSheet.PivotTables("PTMonthlyAnalystSalesSA").PivotFields("SA").CurrentPage = ActiveSheet.Range("B1").Value

However, occassionally the value I in B1 does not exist in the Pivot Table
field "SA" and I get a run time error. I'm not sure how to insert a basic
error checking routine that inserts the value "(blank)" when an error occurs.

Any advice would be much appreciated.

Thanks,
Ra
 
M

Marcus Langell

Try this:

sub yoursub()
On Error Goto ErrFi
ActiveSheet.PivotTables("PTMonthlyAnalystSalesSA").PivotFields("SA").CurrentPage = ActiveSheet.Range("B1").Value
Exit Sub
ErrFix:
MsgBox "Value does not exist
ActiveSheet.PivotTables("PTMonthlyAnalystSalesSA").PivotFields("SA").CurrentPage = "(blank)"
End Sub

/Marcus
 
Top