Need a Error Handling for this Macro

Q

Qull666

Please help.

I have this Macro. But the problem starts when there is no data in the pivot
table or no data in the data source. It will prompt a run time error 1004.

Private Sub Worksheet_Activate()
Me.PivotTables(1).PivotCache.Refresh
Range("C1").Activate
End Sub

I believe there is a way to exit this sub if running this sub causes an error.

Thanks.
 
J

Jacob Skaria

Private Sub Worksheet_Activate()
On Error Resume Next
Me.PivotTables(1).PivotCache.Refresh
Range("C1").Activate
End Sub
 
Q

Qull666

Thanks... it works.

Jacob Skaria said:
Private Sub Worksheet_Activate()
On Error Resume Next
Me.PivotTables(1).PivotCache.Refresh
Range("C1").Activate
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top