VBA ScrollArea = "Range"

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
Code:
Sub SheetScroll()


Dim i As Long


For i = 1 To Sheets.Count Step 2
    Sheets("Sheet" & i).ScrollArea = "A1:L80"
Next i


For i = 2 To Sheets.Count Step 2
    Sheets("Sheet" & i).ScrollArea = "A1:BK80"
Next i


End Sub
 
Last edited:
Upvote 0
Hi mrshl9898,

Thank you! I can't wait to try it out!

Pin
 
Upvote 0
Hi mrshl9898,

I'm getting a VBA error:

Run-time '9':
Subscript out of range


Do you know what could be causing this error?

Thanks,
Pin
 
Upvote 0
VBA scroll area for odd sheets

Hi All,

I'm trying to figure out how to set a scroll area for all of my odd sheet numbers in my workbook.

I'm using this code that doesn't work:

Code:
Sub SheetScroll()


Dim i As Long


For i = 1 To Sheets.Count Step 2
    Sheets("Sheet" & i).ScrollArea = "A1:L80"
Next i

End Sub

VBA providers an error that highlights the second line.

Any suggestions?

Thanks,
Pinaceous
 
Last edited:
Upvote 0
Re: VBA scroll area for odd sheets

Try
Code:
    Sheets(i).ScrollArea = "A1:L80"
 
Upvote 0
Re: VBA scroll area for odd sheets

Thy this:
Code:
Sub SheetScroll()
Dim i As Long
    For i = 1 To Sheets.Count Step 2
        Sheets(i).ScrollArea = "A1:L80"
    Next i
End Sub
 
Upvote 0
Re: VBA scroll area for odd sheets

After testing this I realized you need to activate each sheet for this to work.
And this setting is not saved. You must run this script every time you open your workbook.
I had seen postings before about this problem.

Try this script. But you have to run it each time you open your Workbook.


Code:
Sub SheetScroll()
Dim i As Long
    For i = 1 To Sheets.Count
        
        Sheets(i).Activate
        Sheets(i).ScrollArea = "A1:L80"
        
    Next i
End Sub
 
Upvote 0
Try this mate.

It was looking at the name of the sheet previously "Sheet1", "Sheet2" etc. Instead of the index number.

Code:
Sub SheetScroll()




Dim i As Long




For i = 1 To Sheets.Count Step 2
    Sheets(i).ScrollArea = "A1:L80"
Next i




For i = 2 To Sheets.Count Step 2
    Sheets(i).ScrollArea = "A1:BK80"
Next i




End Sub
 
Last edited:
Upvote 0
Re: VBA scroll area for odd sheets

@MAIT
Whilst I agree that the scrollarea is lost when you close the workbook, for me it works on on inactive sheets.
I'm running the 32bit version of 2013 on win7, what are you running?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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