slight adjustment to existing code.

omairhe

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

I wanted to adjust the row scroll when the following code runs.

Code:
Sub search_a()
   Dim Fnd As Range
   Set Fnd = Range("H:H").Find("b*", , xlValues, xlWhole, , , False, False)
   If Not Fnd Is Nothing Then Cells(Fnd.Row, ActiveCell.Column).Activate
End Sub

the above code will take me to the first instance of a word starting from the letter "b" however, the row will sometimes be down the screen or sometimes on top of the screen and other times at the center. Could someone program it so the searched word is at the center of the screen always.

will appreciate.

Thank u.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Please try this:

Code:
If Not Fnd Is Nothing Then
  Application.Goto Cells(Fnd.Row, ActiveCell.Column), scroll:=True
End If
 
Upvote 0
Please try this:

Code:
If Not Fnd Is Nothing Then
  Application.Goto Cells(Fnd.Row, ActiveCell.Column), scroll:=True
End If

scroll:=True seems interesting. Please guide me as to how to use the scroll True for the arrow keys aswell. for instance an arrow down is pressed then scroll true. along with down.
 
Upvote 0
According to Microsoft

[FONT=&quot]True[/FONT][FONT=&quot] to scroll through the window so that the upper-left corner of the range appears in the upper-left corner of the window. [/FONT][FONT=&quot]False[/FONT][FONT=&quot] to not scroll through the window. The default is [/FONT][FONT=&quot]False[/FONT][FONT=&quot].[/FONT]
 
Upvote 0
I'm not sure I understand your question regarding the "Arrow keys"


Ok suppose I am at row 1 of column A. I hit the down key and this will take me to row 2 of column A. All good but what I additionally need now is that the first row be scrolled up. and this will make the row 2 be on top of screen window instead of the first row.

does it make any sense? thanks for your time.
 
Last edited:
Upvote 0
Are you asking to scroll in real time without the code; just normal arrow down in the worksheet? if so, then turn on your SCROLL LOCK temporarily. Or use your mouse wheel.

Normally I wouldn't even select cells in my code unless it was the very last thing I do in the SUB. I reference cells by their address to copy and paste. You can use the same code I provided to GOTO a cell, no matter the distance from the the last selected cell.

Jeff
 
Upvote 0
Are you asking to scroll in real time without the code; just normal arrow down in the worksheet?

Kind of , Yes.

something like...
Code:
    ActiveWindow.ScrollRow = Selection.Row
    ActiveWindow.ScrollColumn = Selection.Column
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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