Select cell in column A of a ScrollRow

2Took

Board Regular
Joined
Jun 13, 2022
Messages
203
Office Version
  1. 365
Platform
  1. Windows
Trying to get VBA to select cell in column A of a scroll row, meaning when top few rows are frozen and bottom portion of sheet is scrolled up, and top row there might be row 500 - need it to select A500, but getting this error:

2022-09-21_13h17_54.png


VBA Code:
Sub testA()
  ActiveWindow.ScrollRow.Column(1).Select
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Maybe try...

VBA Code:
Sub TopvisibleRow()
Dim xCell As Range
    With ActiveWindow.VisibleRange
      Set xCell = Cells(.Row, .Column)
    End With
   
    xCell.Select
End Sub
 
Upvote 0
I just edited your code with .Column - 1), as my sheet also has A column frozen and it was selecting B column. Thanks!
 
Upvote 0
You're welcome

I just edited your code with .Column - 1), as my sheet also has A column frozen and it was selecting B column. Thanks!
If that is the case as I only used .Column for consistency in the code (as you didn't mention any columns being frozen), you might as well use one of the codes below rather than have Excel calculate then adjust the column reference

Code:
Sub TopvisibleRow()
Dim x As Range
    With ActiveWindow.VisibleRange
      Set x = Cells(.Row, 1)
    End With
    
    x.Select
End Sub
or
VBA Code:
Sub TopvisibleRow()
Dim x As Range
    With ActiveWindow.VisibleRange
      Set x = Cells(.Row, "A")
    End With
    
    x.Select
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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