Find the row

  • Thread starter Thread starter Ant
  • Start date Start date
A

Ant

I have two worksheets one with data and on with a form I would like to find
the row that is selected on the data sheet and use it on the form sheet.

myRow = ActiveWorkbook.Worksheets("Data").ActiveCell.Row

I cannot find a way for this to happen. I have this in a module procedure
which I call when the form sheet is activated.

any help would be greatly appreciated

Anthony
 
The Activecell belongs to a window or the application--not the worksheet.

So one way is to go to that worksheet and look at the activewindow:

Dim myRow As Long
Dim ActCell As Range
Dim CurSel As Range

Application.ScreenUpdating = False

Set CurSel = Selection
Set ActCell = ActiveCell

Worksheets("sheet2").Select
myRow = ActiveWindow.ActiveCell.Row
MsgBox myRow

Application.Goto CurSel
ActCell.Select

Application.ScreenUpdating = True
 
Back
Top