Macro- don't look in the first row

Status
Not open for further replies.

rubinda

New Member
Joined
Jun 26, 2018
Messages
36
The code I have below works well with the exception of one thing: Everything in row 1 is a heading and I don’t want the macro to look there. When I run this macro, if column E=”Complete” and the next cell in column F is blank it works well, but then it looks back at cell F1. How do I stop that?

Sub Edgewood()
Dim Mws As Worksheet
Dim Cws As Worksheet
Dim i As Long

Set Mws = Worksheets("Edgewood")
Set Cws = Worksheets("Edgewood-Closed")

For i = Mws.Range("E" & Rows.Count).End(xlUp).Row To 1 Step -1
If Range("E" & i).Value = "Complete" And IsDate(Range("F" & i).Value) Then
Rows(i).Copy Cws.Range("A" & Rows.Count).End(xlUp).Offset(1)
Rows(i).Delete
Else
MsgBox "There is no data in cell F" & i


ActiveWorkbook.Save

End If
Next i
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Perhaps this..

Code:
Sub Edgewood()
Dim Mws As Worksheet
Dim Cws As Worksheet
Dim i As Long


Set Mws = Worksheets("Edgewood")
Set Cws = Worksheets("Edgewood-Closed")


For i = Mws.Range("E" & Rows.Count).End(xlUp).Row To 1 Step -1
    If i <> 1 Then  ''' to avoid 1
        If Range("E" & i).Value = "Complete" And IsDate(Range("F" & i).Value) Then
            Rows(i).Copy Cws.Range("A" & Rows.Count).End(xlUp).Offset(1)
            Rows(i).Delete
        Else
        MsgBox "There is no data in cell F" & i
        ActiveWorkbook.Save
    End If
   End If
Next i
End Sub
[CODE]

[/CODE]
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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