Userform loads on workbook open but should not

muhleebbin

Active Member
Joined
Sep 30, 2017
Messages
252
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
I have a userform that is supposed to load when a pivottableupdate occurs (change in year is selected in a slicer), however when I open the workbook, it pops up the userform. I have unchecked the box for 'Refresh data when opening the file' however suspect it's due to this code that dynamically adds the year to the slicer as the years pass:

VBA Code:
Private Sub Workbook_Open()

Dim lr As String
lr = Sheets("Lists").Range("C1").Value

Application.ScreenUpdating = False

    With Sheets("Year").ListObjects("Table2")
        If Not .DataBodyRange Is Nothing Then
            .DataBodyRange.Delete
        End If
    End With
Sheets("Year").Range("A2").Formula = "=IF(Lists!$B$1-2013>=ROW(),ROW()+2013,"""")"
Sheets("Year").Range("A2:A" & lr).FillDown

ActiveWorkbook.RefreshAll

Application.ScreenUpdating = True

Call hideMyForm

End Sub

Call hideMyForm contains the following in hopes to unload the form however it is not working as expected. Is there a way to disable this form on workbook open?

Thanks

VBA Code:
Sub hideMyForm()

Unload OAR

End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Placing a single quote mark in front will keep it from running.

VBA Code:
'Call hideMyForm
 
Upvote 0
But I want it to unload the form that pops up on open.

I think the code above it recreates the data set that the pivottable builds off of which I think is causing the issue.
 
Upvote 0
Try replacing Call hidemyform
With Unload OAR
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,651
Members
449,326
Latest member
asp123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top