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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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