How to Update Mastersheet

How to update mastersheet using updated data in monthly reports. Often we update our manpower data if we are a recruitment firm or our purchase prices if we are a sales or production organization. In such cases we may need to update our master data. We learn today how this process of updating of data can be automated using Excel VBA. Watch the video below:

Watch this video on YouTube.

Here’s the complete VBA code for updating data in a master worksheet with VBA:

Sub updateMasterSheetFromMonthlyReport()
Dim personName As String, companyName As String
Application.ScreenUpdating = False
Workbooks.Open (“C:\Users\takyar\Desktop\mymonthlyreport.xlsx”)
lastrowMR = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrowMR
personName = Cells(i, 1)
companyName = Cells(i, 2)

lastrowMS = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row

For p = 2 To lastrowMS
If Cells(p, 1) = personName And Cells(p, 2) <> companyName Then
Cells(p, 1) = personName
Cells(p, 2) = companyName
End If
Next p
Next i


Application.ScreenUpdating = True

End Sub

Further reading:

Nested Loops