Hello, bit of a VBA newbie here coming for some (hopeful!) guidance. Below you will find my code for an ongoing project I am working through. My goal with this macro is to update the master sheet off a generated report that is sent to me using Vlookup. If the lookup value is found on the generated report but not the master, the entire row would be cut and added to the master. Any suggestions to help getting to a functional place would be greatly appreciated!
Thanks,
uncxx
Code:
[/FONT][/SIZE]Option ExplicitSub SQUpdater()
'Define lookup value
Dim EmpEmail As String
'Define lookup array
Dim UltiProR As Range
'Define EmpInfo
Dim EmpInfo As String
'Define results array
Dim SQ As Range
'Define result cell
Dim resultRow As Long
'Define count to get to last item in the lookup column
Dim finalRow As Long
'Define counter
Dim i As Long
'Set lookup array
Set UltiProR = Sheets("UPWB").Range("A2:H351")
'Set result array
Set SQ = Sheets("Master").Range("A2:H800")
'establish final row
finalRow = Cells(Rows.Count, 1).End(xlUp).Row
'Loops
For i = 2 To finalRow
'Set employee email/lookup value
EmpEmail = Sheets("UPWB").Cells(i, 4).Value
'if an error occurs, go to next line and clear the error
On Error Resume Next
Err.Clear
'Perform Vlookup
EmpInfo = Application.WorksheetFunction.VLookup(EmpEmail, SQ, 4, False)
If EmpEmail <> 0 Then
Sub CutRows()
End If
Next i
End Sub
Sub CutRows()
For Each ws In Sheets
'moves through every worksheet
With ws
If .Name = "UPWB" Then
lastrow = .Range("A" & Rows.Count).End(xlUp).Row
'determines the lastrow
For i = lastrow To 1 Step -1
'moves from bottom to top
If (.Range("D" & i).Value) <> EmpEmail
Then (.Range("D" & i).EntireRow.Cut,
Destination:=Master.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
Next i
End If
End With
End Sub
Thanks,
uncxx