Macro Tweak - Selecting Active Cell

littlefish

New Member
Joined
Mar 6, 2008
Messages
18
Office Version
  1. 365
Platform
  1. 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
_________________________________________________________________________

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:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
How about
Code:
Sub UPDATE_CODE()
    Application.ScreenUpdating = False
    Range("A" & activecell.Row).Resize(, 6).Copy Range("TARGET.LIST")
    Range("TARGET.LIST").Offset(1).Name = "TARGET.LIST"
End Sub
 
Upvote 0
Solution
Thanks, Fluff. That gets me there. (Also, thank you for reformatting my code correctly.)
Have a great day.

Ted
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,852
Members
449,096
Latest member
Erald

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