scrollable workarea

meraldo

New Member
Joined
Jun 13, 2003
Messages
28
I have this routine that works upon activation of each worksheet. But since rows can be inserted&added into such worksheets I would need it to change dynamically.i.e. when I add a row, this range sould automatically be "A1:AI28"
can someone hlp? (y)

Private Sub Worksheet_Activate()
Me.ScrollArea = "A1:AI27"
...
'To set back to normal use:
'Me.ScrollArea = ""
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,

Use names for this .

In my code I have named the ScrollArea Range 1:AI28 as "Meraldo".Change this to suit your needs.

After naming the range using the Name Box, Right Click the worksheet Tab , Choose View Code and paste the following:

Code:

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Activate()
    Me.ScrollArea = Range("Meraldo").Address
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)
    Me.ScrollArea = Range("Meraldo").Resize(Range("Meraldo").Rows.Count).Address
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

Now the Scroll Area will adjust automatically as you insert/Delete Rows.

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,215,350
Messages
6,124,430
Members
449,158
Latest member
burk0007

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