VBA- Macro to move entire row of data to new sheet, based on a cell value

Garrek

Board Regular
Joined
Aug 22, 2019
Messages
53
Good morning all,

I'm looking to make a macro to move a full row (columns A-M) from one sheet to another, based on a value in column A. In the first sheet (Sheet1), Column A is populated entirely with unique values. My hope is that the macro could read a cell (B14) containing one of these values on a different sheet (Sheet3), then look up that value, copy the entire row that it is, and paste it onto the target sheet (Sheet2).

Could anyone provide help on this? Let me know if you have any clarifying questions.
 
That looks fine, is it copying over the data, but not changing col C on sheet2?
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Disregard that, I messed up the Withs and such. Amateur here! Got it to work. Thanks a ton for all the help.
 
Upvote 0
Glad it's working & thanks for the feedback
 
Upvote 0
That looks fine, is it copying over the data, but not changing col C on sheet2?


Got it to work, my bad.

Here's the final code:



Code:
Sub RetireMove()
   Dim Fnd As Range
   
   With Sheets("Sheet1")
      Set Fnd = .Range("A:A").Find(Sheets("Sheet3").Range("B14").Value, , , xlWhole, , , False, , False)
      End With
   If Not Fnd Is Nothing Then
      With Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp)
         Fnd.Resize(, 13).Copy .Offset(1)
         .Offset(1, 2).Value = "Inactive"
         Fnd.EntireRow.Delete
      End With
   Else
      MsgBox "nothing found"
   End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

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