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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

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