51DegreesNorth
New Member
- Joined
- Mar 29, 2022
- Messages
- 11
- Office Version
- 365
- Platform
- Windows
Hi,
In my project, the Worksheet_Change event performs some actions. When all is done, I'd like to return the user to the cell where it all started, without firing the on change event again.
The last line of code errors out. If the orginal active cell was A1, then RetAdr contains $A$1. Declaring RetAdr as range does not fix it.
I"d like to get rid of the error. Also I'd like a a more efficient way to locate Src_PO_Nr - searching in an entire column seems overkill.
Your help much appreciated.
In my project, the Worksheet_Change event performs some actions. When all is done, I'd like to return the user to the cell where it all started, without firing the on change event again.
VBA Code:
Dim Src_PO_Nr As Long
Dim DestRow As Long
Dim SrcRow As Long
Dim RetAdr As String
'active cell determined by user (new entry or edit cell)
Src_PO_Nr = Cells(ActiveCell.Row, 1)
SrcRow = ActiveCell.Row
RetAdr = ActiveCell.Address
'
Worksheets("Some Sheet").Activate
DestRow = Application.WorksheetFunction.Match(Src_PO_Nr, Range("A:A"), 0)
Sheets("Some Sheet").Rows(DestRow).Value = Sheets("Some other Sheet").Rows(SrcRow).Value
Worksheets("Some other Sheet").Range("RetAdr").Offset(1).Select
The last line of code errors out. If the orginal active cell was A1, then RetAdr contains $A$1. Declaring RetAdr as range does not fix it.
I"d like to get rid of the error. Also I'd like a a more efficient way to locate Src_PO_Nr - searching in an entire column seems overkill.
Your help much appreciated.