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
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
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" <Mili@discussions.microsoft.com> wrote in message
news:020660C5-F3A7-425C-8092-C5B4757466BF@microsoft.com...
> 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
Hello Mili,
The IF statement is a basic construct used by all programming languages. Form machine code to high level compiler languages, this statement is used to make a 2 decisions based on the result of the expression being tested. If the expression tests true do something, and do something else if it is false.
If Example:
If A = B Then
'Code for True result goes here
Else
'Code for False result goes here
End If
Sincerely,
Leith Ross
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks