How to update a master worksheet with the click of a button automatically with VBA. Watch the video below:
Here’s the complete VBA code:
Sub updateMasterSheet()
Dim i As Long, j As Long, lastrowmaster As Long, lastrowreport As Long
lastrowmaster = Sheets(1).Range(“A” & Rows.Count).End(xlUp).Row
lastrowreport = Sheets(2).Range(“A” & Rows.Count).End(xlUp).Row
Sheets(1).Activate
For i = 2 To lastrowmaster
Sheets(2).Activate
For j = 2 To lastrowreport
If Sheets(1).Cells(i, 1) = Sheets(2).Cells(j, 1) Then
Sheets(1).Cells(i, 4) = Sheets(2).Cells(j, 4)
End If
Next j
Sheets(1).Activate
Next i
End Sub