VBA script needed to select cells in an active row, copy and paste values only into other cells in the same row.

Anonymous
2024-05-03T19:01:18+00:00

I am using Office 365 on a Windows PC. I have an Excel workbook with two tabs - Call Log and Member List. There are at least three common columns on each tab - Member Name, ID # and DOB. ID #'s are unique.

When I enter an ID # in the Call Log column C there is an Index/Match formula that looks up the Member Name and DOB. This info appears in the green columns.

With four helper columns I can also find the ID # if the Member Name and DOB are provided. This info appears in the purple columns.

The workbook is Macro enabled. In the Call Log $H$1 is labeled ColNo and $I$1 is labeled RowNo. These cells display the active row and column numbers.


What I would like to do is create a macro for a button. When the button is selected the macro will do the following steps:

  1. Read the number in the RowNo cell (which will be the active row). This may be an unnecessary step.
  2. Select the cells in columns J, K and L in the active row.
  3. Copy the data.
  4. Go to column B in the active row.
  5. Paste Special, Values Only. This will overwrite the data in columns B, C and D in the active row.

I can't make it work with the Record Macro function. All help will be greatly appreciated.

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Anonymous
    2024-05-04T02:54:13+00:00

    Could you share a test workbook? Then I will have a try on it.

    For sharing a sample workbook, upload to OneDrive or any other cloud drives. Then post a link here.

    Why a sample file is important for troubleshooting. How to do it. - Microsoft Community

    0 comments No comments
  2. Andreas Killer 144K Reputation points Volunteer Moderator
    2024-05-04T08:23:51+00:00

    Sub Test()
    Intersect(Range("B:D"), ActiveCell.EntireRow).Value = Intersect(Range("J:L"), ActiveCell.EntireRow).Value
    End Sub

    0 comments No comments
  3. Anonymous
    2024-05-06T02:41:41+00:00
    0 comments No comments
  4. Anonymous
    2024-05-06T03:25:31+00:00

    Here's the macro code to copy data from the specified cells:

    =======

    Sub CopyData()

    'Copy data from J to B 
    
    Range("B" & ActiveCell.Row).Value = Range("J" & ActiveCell.Row).Value 
    
    'Copy data from L to D 
    

    Range("D" & ActiveCell.Row) = Range("L" & ActiveCell.Row).Value

    'Copy data from K to C and upper cell C 
    
    Range("C" & ActiveCell.Row).Value = UCase(Range("K" & ActiveCell.Row)) 
    

    End Sub

    =======

    0 comments No comments