View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default "if" statement within a macro


Dim iLastRow As Long
Dim i As Long
Dim rng As Range
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i, "A").Value = "Not Current" Then
If rng Is Nothing Then
Set rng = Rows(i)
Else
Set rng = Union(rng, Rows(i))
End If
End If
Next i

If Not rng Is Nothing Then
rng.Copy Destination:=Worksheets("Sheet2").Range("A1")
End If


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mili" wrote in message
...
I have a list of employee and when the button "update employees" is

selected
I want the macro to cut and paste employess who are marked not current to
another page. I don't know how to use an IF statement within a macro.

Please
help