Basic if , then , move help please

karl_everest

New Member
Joined
Apr 13, 2011
Messages
1
Hi,
I need a code to do the following
IF A CELL IN COLUMN H=INACTIVE THEN MOVE THE COROSPONDING ROW TO TO SHEET2. PLEASE HELP, I HAVEN'T USED EXCEL IN SO LONG I AM LOST, I HAVE TRIED GOOGLING BUT CANT FIND THE COMMANDS
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Welcome to the board. You don't say where in Sheet2 you want the found row moved to, so to begin with you can use the code below then modify it:

Code:
Sub LastPenguinInExistance()
Dim i As Long, j As Long
With Application
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
End With
If IsEmpty(Sheets("Sheet2").Range("A1")) Then j = 0
With Sheets("Sheet1")
    For i = 1 To .Range("H" & Rows.Count).End(xlUp).Row
        If .Range("H" & i) = "INACTIVE" Then
            .Rows(i).Copy
            If j = 0 Then
                Sheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteAll
                j = 1
            Else
                With Sheets("Sheet2")
                    j = .Range("H" & Rows.Count).End(xlUp).Offset(1, 0).Row
                    .Range("A" & j).PasteSpecial Paste:=xlPasteAll
                End With
            End If
        End If
    Next i
End With
With Application
    .ScreenUpdating = True
    .Calculation = xlAutomatic
    .CutCopyMode = False
End With
End Sub
 
Upvote 0
IMO, a quicker method would be to filter column H for values of "INACTIVE" and then move all the visible rows into Sheet2. You can record a macro and then review the code to see how this is done.
 
Upvote 0

Forum statistics

Threads
1,215,482
Messages
6,125,061
Members
449,206
Latest member
Healthydogs

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