littlefish
New Member
- Joined
- Mar 6, 2008
- Messages
- 18
- Office Version
- 365
- Platform
- Windows
Good morning.
I have a spreadsheet with two tabs. One contains data that gets manually updated. For each row updated, I run a macro which copies the unique code ID (column F) to a second tab. The macro runs fine as-is, except in the cases where there are blank columns of data for any given row, and this trips up the xlToLeft step. May I please get some help to tweak the macro so that column F of the active row is selected to be copied regardless of where on that specific row the active cell is?
Thanks so much in advance. My macro is below (Courier font, hopefully.)
Ted
_________________________________________________________________________
I have a spreadsheet with two tabs. One contains data that gets manually updated. For each row updated, I run a macro which copies the unique code ID (column F) to a second tab. The macro runs fine as-is, except in the cases where there are blank columns of data for any given row, and this trips up the xlToLeft step. May I please get some help to tweak the macro so that column F of the active row is selected to be copied regardless of where on that specific row the active cell is?
Thanks so much in advance. My macro is below (Courier font, hopefully.)
Ted
_________________________________________________________________________
Code:
[FONT=courier new]Sub UPDATE_CODE()
Application.ScreenUpdating = False
ActiveWorkbook.Names.Add Name:="BEGIN.TZ", RefersToR1C1:=ActiveCell 'Name active cell "goto" once the main process ends
Selection.End(xlToLeft).Select 'Active cell to column A on same row as data entered (this doesn't work if there are blank cells between starting point)
ActiveCell.Offset(0, 5).Range("A1").Select 'Active cell to column F (CODE ID) on same row as data entered
Selection.Copy 'Copy CODE ID
Application.Goto Reference:="TARGET.LIST" 'Go to target with list of CODE IDs for updated data
ActiveSheet.Paste 'Paste CODE ID
Application.CutCopyMode = False
ActiveWorkbook.Names("TARGET.LIST").Delete 'Delete current target for next update
ActiveCell.Offset(1, 0).Range("A1").Select 'Active cell down one row
ActiveWorkbook.Names.Add Name:="TARGET.LIST", RefersToR1C1:=ActiveCell 'Name active cell "goto" for next target
Application.Goto Reference:="BEGIN.TZ" 'Return to original cell location
ActiveWorkbook.Names("BEGIN.TZ").Delete 'Delete "goto" anchor cell
End Sub[/FONT]
Last edited by a moderator: