Scroll Area

G

Guest

Is there any way of setting the scroll area of a spread sheet ie: using the
..scrollarea = function in VB where the scroll area may not be known at the
time of writing the vb code.

Instead of using activesheet.scrollarea = "a1:p34"

I want to use activesheet.scrollarea = range1 : where range1 has been
determined

Can this be done?
 
D

David McRitchie

instead use:
ActiveSheet.ScrollArea = "range1"
and to remove
ActiveSheet.ScrollArea = ""
 
R

Ron de Bruin

Hi Ashman

You can use this

Set rng = Range("A4:E10")
ActiveSheet.ScrollArea = rng.Address

Or

Set rng = Range("A1").CurrentRegion
ActiveSheet.ScrollArea = rng.Address
 
D

David McRitchie

A better example: This will toggle between range1 as scroll area
and removing the scroll area limitations on mouse, arrow keys, scrolling, etc.

Private Sub Worksheet_BeforeRightClick(ByVal Target _
As Range, Cancel As Boolean)
Cancel = True
If ActiveSheet.ScrollArea = "" Then
ActiveSheet.ScrollArea = "range1"
Else
ActiveSheet.ScrollArea = ""
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top