Method 'Range' of object _'Global' failed (while using Range to select cells)

BusinessMonkey

New Member
Joined
Jun 4, 2014
Messages
5
I have been using this piece of code within the same workbook, on other sheets and it works just fine. It simply selects a range of cells and uses the "Zoom to Selection" function aka "ActiveWindow.zoom = true" to fit the sheet properly on the screen. I use this because the workbook is opened on different computers with different sized monitors. When I use this piece of code on one particular sheet, I get this error: "Method 'Range' of object _'Global' failed".

here is my code:



Code:
'FIX VIEW


            Application.DisplayAlerts = False
            Application.ScreenUpdating = False
[U]            Range("A1:023").Activate[/U]


            ActiveWindow.Zoom = True
            Cells(5, 7).Select

I am new to VBA. I am pretty sure this has something to do with the fact that "Range" doesn't know what cells I'm referring to. but I have also tried replacing the code with whats below and I get the same error...

Code:
'FIX VIEW


            Application.DisplayAlerts = False
            Application.ScreenUpdating = False
[U]            Workbook("DCSLOG").Sheets("APercentData").Range("A1:023").Activate[/U]


            ActiveWindow.Zoom = True
            Cells(5, 7).Select

(the underlined code is what gives the error)

Thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
2 problems

1. You can't select/activate a range on a sheet that is not already active.
You have to select/activate that sheet first, THEN select/activate the range.
Sheets("sheetname").Select
Range("A1:A10").Select


2. That looks like a zero, I'm guessing it should be the Letter O ?
Range("A1:023")
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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