codeliftsleep
Board Regular
- Joined
- Apr 14, 2017
- Messages
- 103
This is a very strange error...Whats happening is I have various users looking at information. I have pivot tables that are updated daily and then filtered to display only the information for that user. However, the pivot tables were causing all kinds of issues refreshing properly so I scrapped this and now Delete and rebuild the pivot tables and slicers each time a user logs in.
It appears it is happening due to a timing issue. I have the following code:
the first time through, it throws the error in the Title if I run the code by itself. However, once it goes through the error handler, logs it and pops up the error in a message box to the users, and resumes, if I go down to the s.NumberOfColumns = 8 line of code and run it, it works without any issues. As it does it if I step through the code line by line using F8.
The only time it throws an error is when it runs by itself. Any ideas how to make sure this doesn't happen? Do I add a 3 second pause in there or something before I set the number of columns?
Seems really weird and it's these type of things that are really frustrating in VBA...no reason for that to be popping up other than the code is running before s is set in code.
It appears it is happening due to a timing issue. I have the following code:
Code:
ThisWorkbook.SlicerCaches("Slicer_AGING_BUCKET").Delete
'Create a new slicer
Dim sc As SlicerCaches
Dim sl As Slicers
Dim s As Slicer
Set sc = ThisWorkbook.SlicerCaches
Set sl = sc.Add2(CurDayIP.PivotTables(1), "AGING BUCKET", "Slicer_AGING_BUCKET").Slicers
Set s = sl.Add(CurDayIP, , "Slicer_AGING_BUCKET", "Choose Aging Buckets to View", 0, 0, 800, 50)
s.NumberOfColumns = 8
the first time through, it throws the error in the Title if I run the code by itself. However, once it goes through the error handler, logs it and pops up the error in a message box to the users, and resumes, if I go down to the s.NumberOfColumns = 8 line of code and run it, it works without any issues. As it does it if I step through the code line by line using F8.
The only time it throws an error is when it runs by itself. Any ideas how to make sure this doesn't happen? Do I add a 3 second pause in there or something before I set the number of columns?
Seems really weird and it's these type of things that are really frustrating in VBA...no reason for that to be popping up other than the code is running before s is set in code.
Last edited: