Hi All,
I have been given a file with this code. My understanding is that this macro update pivot tables when the correct "ID" is entered. However, because the ID are entered in manually, we had user entering un-identified ID or ID with missing digits and then the macro stop working and it requires some debugs action - which is freaking out staff.
As I am not great with macro, greatly appreciate advice on how to change this macro so that it will stop the macro and show a message box to say something like 'ID not found.' Many thanks in advance.
I have been given a file with this code. My understanding is that this macro update pivot tables when the correct "ID" is entered. However, because the ID are entered in manually, we had user entering un-identified ID or ID with missing digits and then the macro stop working and it requires some debugs action - which is freaking out staff.
As I am not great with macro, greatly appreciate advice on how to change this macro so that it will stop the macro and show a message box to say something like 'ID not found.' Many thanks in advance.
Code:
Sub update()
Application.ScreenUpdating = False
Dim control As Worksheet
Dim dataLink As Worksheet
Set control = Worksheets("control")
Set dataLink = Worksheets("data")
For i = 2 To 11
Sheets(control.Range("A" & i).Value).PivotTables(control.Range("B" & i).Value).PivotFields("ID").ClearAllFilters
Sheets(control.Range("A" & i).Value).PivotTables(control.Range("B" & i).Value).PivotFields("ID").CurrentPage = Sheets("control").Range("control!E1").Value
Next i
Application.ScreenUpdating = True
End Sub