2 Workbooks, updating 1 Value [Err 1004]

uncxx

New Member
Joined
Jun 4, 2018
Messages
2
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.

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
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top