Scroll to SheetChange..

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
Office Version
  1. 2019
Platform
  1. Windows
Hey everyone,

I would appreciate some help on using the sheet change event with scrolling. For instance, how would I Scroll to the target cell that triggered sheet change event.

One way to achieve is to use the following two lines

Code:
 ActiveWindow.ScrollRow = Selection.Row
 ActiveWindow.ScrollColumn = Selection.Column

But on pressing enter over target cell upon change. it will scroll aswell which requires me to insert one more line like this

Code:
 ActiveWindow.ScrollRow = Selection.Row
 ActiveWindow.ScrollColumn = Selection.Column
 ActiveWindow.SmallScroll Down:=-1

But what if the user used a down arrow key or up or left or right or tab key.

ActiveWindow.SmallScroll Down:=-1 this will work only with Enter key.


Help will be appreciated
thank you
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
If you click on B45 to make a change to cell B45 why do you need a script to scroll to B45?
Your already at B45

Or am I missing something.
 
Upvote 0
If you click on B45 to make a change to cell B45 why do you need a script to scroll to B45?
Your already at B45

Or am I missing something.

You need to try this code in the workbook category

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Source As Range)
 Application.ScreenUpdating = False
 ActiveWindow.ScrollRow = Selection.Row
 ActiveWindow.ScrollColumn = Selection.Column
 ActiveWindow.SmallScroll Down:=-1
 Application.ScreenUpdating = True
End Sub

Before you do also FreezePane both column and row on cell G2 . Now enter values in column H in descending order. Note that my data has alphabetical order of items in column A.

There are three advantages .
1. Your recent entry will appear on top.
2. You can recheck what you typed against value in column A as it will be at the top and easily viewable.
3. You make more room for yourself on the screen each time you enter a new value.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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