Help with small scroll lock code

g_OUELLET

New Member
Joined
Mar 9, 2009
Messages
43
Trying to set code for a scroll lock so we do not go past Colum E. Can go from A3:E203. But not past column "E" I get Run time Error 9" This is what I have.

Private Sub Workbook_Open()
Worksheets("RestaurantCharges").ScrollArea = "A3:E3"
End Sub

Deleted Image - It was blowing up the page & had actual personal information - Moderator
 
Last edited by a moderator:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
There's nothing wrong with your code, so I'd suspect the sheet name. Does the "RestaurantCharges" sheet really have no space inbetween t/C? Note that when code refers to a sheet name it needs to be exact - even a leading or trailing space can throw it off.

HTH,
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,273
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
Hi
You code works Ok for me, but I change dthe scroll area to meet your range
Code:
Private Sub Workbook_Open()
Worksheets("RestaurantCharges").ScrollArea = "A3:E203"
End Sub
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,273
Office Version
  1. 365
  2. 2007
Platform
  1. Windows

ADVERTISEMENT

Did you note Smitty's comment about sheet names being EXACT.
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,273
Office Version
  1. 365
  2. 2007
Platform
  1. Windows

ADVERTISEMENT

The code you posted will only "LOCK" the "RestaurantCharges", nothing else.
Are you saying you want all sheets locked the same way.
 

g_OUELLET

New Member
Joined
Mar 9, 2009
Messages
43
The code you posted will only "LOCK" the "RestaurantCharges", nothing else.
Are you saying you want all sheets locked the same way.

Yes all sheets in the workbook. The file name is "Restaurant Charges" inside I have (1) tab "Employee setup" another tab "Sum Sheet" the rest are "Pay Period 1 Pay Period 2 etc.. to "Pay Period 26 these are the sheets i need the scroll lock.
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,273
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
Try this
Code:
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
    If ws.Name <> "Employee setup" And ws.Name <> "Sum Sheet" Then
        ws.ScrollArea = "A3:E203"
    End If
 Next
End Sub
 

g_OUELLET

New Member
Joined
Mar 9, 2009
Messages
43
Try this
Code:
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
    If ws.Name <> "Employee setup" And ws.Name <> "Sum Sheet" Then
        ws.ScrollArea = "A3:E203"
    End If
 Next
End Sub

Thank you, Thank you, Thank you
Works great
Gilles
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,428
Messages
5,831,572
Members
430,075
Latest member
Tuturino

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