Copy complete row into another sheet based on data from drop down menu

Bri_11

New Member
Joined
Feb 18, 2015
Messages
1
I have a simple spreadsheet in Excel 2013 of a workplan in sheet 1. In Column H, you can choose from a drop down menu who needs to be working on certain tasks.

Because the list of activities is long, I want to copy the whole row to Sheet 2 whenever SM is chosen in column H.

I have never worked with VBA code and tried copying it from forums and putting in my variables but it's not working.

Sub MoveClosed()
Dim lr As Long, lr2 As Long, r As Long
lr = Sheets("Sheet 1").Cells(Rows.Count, "H").End(xlUp).Row
lr2 = Sheets("Sheet 2").Cells(Rows.Count, "H").End(xlUp).Row
Sheets("Sheet 1").Activate
For r = 2 To lr
If Range("H" & r).Value = "SM" Then
Rows(r).Copy
Sheets("Sheet 2").Rows(lr2 + 1).PasteSpecial Paste:=xlPasteValues
End If
Rows(r).Delete
Next r
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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