![]() |
Basic Error Checking in Excel VB
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 |
Try this:
sub yoursub() On Error Goto ErrFix 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 "RestlessAde" wrote: 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 |
All times are GMT +1. The time now is 06:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com