Error Message on Workbook Open

gmooney

Board Regular
Joined
Oct 21, 2004
Messages
242
Office Version
  1. 365
Platform
  1. Windows
The following code works fine on my 64bit Excel but not on 32bit: I discovered it I went ahead and stopped the code but then reran it immediately the code would work and perform like it should. Therefore I had to add the Error Resume option and was hoping that it would go ahead and complete the code but it doesn't. I still have to manually run this macro again and all is well.

This code is in "This Workbook"

VBA Code:
Private Sub Workbook_Open()
    Application.ScreenUpdating = False
    Application.WindowState = xlMaximized
    On Error Resume Next
    Sheets("Category Review").Select
    Range("A1:K12").Select
    ActiveWindow.Zoom = True
    Range("A1").Select
    Application.ScreenUpdating = True
    On Error GoTo 0
    
End Sub

Any thoughts on how to get this to work properly?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
2,111
Office Version
  1. 2013
Platform
  1. Windows
On my 32bit Excel 2013 it works as expected.
If it doesn't execute at all, at some point you probably have disabled the occurrence of events while you were not aware of that ...

VBA Code:
Sub RunOnce()
    Application.EnableEvents = True
End Sub

Otherwise you might consider telling us what happens, which error you're getting on which line of code.
 

gmooney

Board Regular
Joined
Oct 21, 2004
Messages
242
Office Version
  1. 365
Platform
  1. Windows
It errors on the Sheets line. When I added the On Error Resume right above that line and then On error GoTo 0 line right below it, it then errored out on the Range. line?
 

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
2,111
Office Version
  1. 2013
Platform
  1. Windows
You're not telling us the number and description of the error.
When there's a typo in the sheet name (a sheet with that particular name does not exist) the code will error.
If the code tries to select a range on a chart the code will error.
For now I have no further suggestions.
 

gmooney

Board Regular
Joined
Oct 21, 2004
Messages
242
Office Version
  1. 365
Platform
  1. Windows
You're not telling us the number and description of the error.
When there's a typo in the sheet name (a sheet with that particular name does not exist) the code will error.
If the code tries to select a range on a chart the code will error.
For now I have no further suggestions.
What I am saying is that this codes works just fine on 1 64bit Office laptop but the same file doesn't on a 32bit laptop so from the code you can see the sheetname is the same on both laptops and the range is the same on both laptops. I am not sure what else you are wanting me to explain? If I need to explain more.

Sheets("Category Review").Select
Range("A1:K12").Select
 

Forum statistics

Threads
1,143,835
Messages
5,721,076
Members
422,339
Latest member
SHIVATVM

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
Top