powercell99
Board Regular
- Joined
- May 14, 2014
- Messages
- 75
Hi, I've been banging my head against the wall trying to determine what i havewrong with my code. I have an employee roster (Sheet1) and I'm trying to get the code to look through Sheet1 and if the Last Name field is NOT "Vacant" or "Recruit" , and the Emp ID Field is not blank, then list it on Sheet2.
But the result pulls in many Vacant and Recruit records when they should be excluded. What am i doing wrong????
Here is my code, any recommendations would be GREEEEAAATTTLYYYY appreciated! I know its a bit sloppy, but i'm a novice.
Thanks so much for looking.
But the result pulls in many Vacant and Recruit records when they should be excluded. What am i doing wrong????
Here is my code, any recommendations would be GREEEEAAATTTLYYYY appreciated! I know its a bit sloppy, but i'm a novice.
HTML:
Sub Test()
'
Dim WSRDL As Worksheet
Dim WSQC As Worksheet
Dim LastRow As Long
Dim LastRowQC As Long
Set WSRDL = Worksheets("Sheet1")
Set WSQC = Worksheets("Sheet2")
LastRow = (WSRDL.Range("A20000").End(xlUp).Row) - 4
LastRowQC = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row + 1
Debug.Print LastRow
Application.ScreenUpdating = False
WSRDL.Activate
Range("A1").Select
For RowNum = 2 To LastRow
Dim EmpID As String
Dim LastName As String
Dim FirstName As String
LastName = Sheets("Sheet1").Cells(RowNum, 1)
EmpID = Sheets("Sheet1").Cells(RowNum, 24)
If (LastName <> "Vacant" Or LastName <> "Recruit") And EmpID = "" Then
WSQC.Cells(LastRowQC, 1).Value = 16
WSQC.Cells(LastRowQC, 5).Value = EmpID
WSQC.Cells(LastRowQC, 6).Value = LastName
WSQC.Cells(LastRowQC, 12).Value = "Emp ID is Blank"
Else
End If
LastRowQC = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row + 1
Next RowNum
Range("A1").Select
End Sub
Thanks so much for looking.