VBA_Move and Delete a cell with condition

lokjing

New Member
Joined
Apr 5, 2013
Messages
1
Dear Mr. Excel,

I have a masterlist file with over 1k row and on the column E I have a employment status which has data list as "Active" and "Inactive" so I need you to help me as I know nothing with VBA.

I need to move rows that contain "Inactive" to another sheet and then that row will delete automaticall on a click.


so can u show me the way as now it is very difficult for a VBA dummy like me.


Thanks in Advances for your kindest help.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Code:
Sub test()
Dim LastRow, i As Long
LastRow = Sheet1.Range("E" & Rows.Count).End(xlUp).Row
n = 1
For i = 1 To LastRow
    If Sheet1.Range("E" & i) = "inactive" Then
        
        Rows(i).Cut
        Sheet2.Activate
        Sheet2.Range("A" & n).Select
        ActiveSheet.Paste
        n = n + 1
    
    End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

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