How to scroll sheet to reveal active cell?

General Ledger

Active Member
Joined
Dec 31, 2007
Messages
460
Dear All,

Using VBA in Excel 2003, how can I make the sheet scroll to show the active cell on the screen?

For example, I have a form on a sheet. When the user gets to the bottom of the form, the top rows have scolled off the screen. This is fine. Then a macro is run and cell B3 is made active. How can I make B3 active and scroll the screen to display B3?

Thanks,

GL
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
First be sure to activate the sheet in question (you can't activate cells unless the sheet is also active):
Code:
Worksheets("Sheet1").Activate

then simply activate the Cell:
Code:
Range("B3").Activate

You can play with scroll rows if you like - just turn on the macro recorder and jump around a bit, entering some data here and there. You'll see how the macro recorder handles it. But the above is probably enough for your needs. I suppose Application.Goto XXX is also good (I seem to always forget about that option).

ξ
 
Upvote 0
This also might work though I did not try it out myself...

application.goto activecell, true
 
Upvote 0
So it seems there are options to bring certain cells into view in the Excel window:

1. This code will make B17 the active cell (places cursor in this cell) and scrolls the screen horizontally (left and right) and vertically (up and down) so B17 is the top left cell of the active window. Column A is scrolled off the left side of the window.

Range("B17").Activate
Application.Goto Activecell, True


2. This code will make B17 the active cell (places cursor in this cell) and scrolls the screen vertically (up and down) so row 5 is the top row. Rows 1 through 4 are scrolled off the top of the window. This does not cause the screen to scroll horizontally (left or right). To do that use ActiveWindow.ScrollColumn

Range("B17").Activate
ActiveWindow.ScrollRow = 5


Thanks,

GL
 
Upvote 0
What Tom Schreiner wrote is correct.
but if you want to see the left side of your sheet, you can use this:

Application.Goto ActiveCell, True
Range("A" & (ActiveCell.Row)).Show

Ivan ;)
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,777
Members
449,336
Latest member
p17tootie

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