I receive an automated report and use it to update an internal file for my department. All columns are formatted almost identically between the two sheets (at least for the two criteria I am working with). My goal is to have a macro that will update our internal file to match the information provided from the automated report.
The 'lookup' value that I am working with can be found in column 5 (E) of both workbooks, while the data I need to verify/update is in column 7 (G). Ideally if the values match, it will go to the next one, but if the values don't match, it will copy from the automated report to the master, and resume with the next. Currently I am trying to assign variables to a lookup value and have them go through the main listing with a counter. I'm not sure if this is the best approach (currently getting a Run-time error '1004'), but I figured I would share the code below so you can see exactly what I am working with.
Any guidance or suggestions to help with my current code would be awesome.
Thanks
The 'lookup' value that I am working with can be found in column 5 (E) of both workbooks, while the data I need to verify/update is in column 7 (G). Ideally if the values match, it will go to the next one, but if the values don't match, it will copy from the automated report to the master, and resume with the next. Currently I am trying to assign variables to a lookup value and have them go through the main listing with a counter. I'm not sure if this is the best approach (currently getting a Run-time error '1004'), but I figured I would share the code below so you can see exactly what I am working with.
Code:
Option Explicit'Define counter
Public i As Long
Sub SalUpdater()
Dim SQ As Range
Dim f As Variant
Dim t As Variant
Dim UP As Range
Dim finalrow As Long
Dim Salary As String
Dim EmpEmail As String
Dim EmpEmail2 As String
finalrow = Sheets("Master").Cells(Rows.Count, 1).End(xlUp).Row
EmpEmail = Sheets("Master").Cells(i, 5).Value
EmpEmail2 = Sheets("UPWB").Cells(i, 5).Value
Set SQ = Sheets("Master").Range("E2:G400")
Set UP = Sheets("UPWB").Range("E2:G400")
f.Value = Application.VLookup(EmpEmail, SQ, 3, False)
t.Value = Application.VLookup(EmpEmail2, UP, 3, False)
For i = 2 To finalrow
On Error Resume Next
Err.Clear
If f = t Then GoTo next1
Else: CuttyCut
next1:
Next i
End If
End Sub
Sub CuttyCut()
Sheets("UPWB").Select
Cells(i, 3).Cut
Sheets("Master").Select
Cells(i, 3).Paste
End Sub
Any guidance or suggestions to help with my current code would be awesome.
Thanks