Update Master Sheet with a Click

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


For i = 2 To lastrowmaster
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

Next i

End Sub