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


Published by

Dinesh Kumar Takyar

Welcome to! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: For a structured Excel VBA training course online you can visit:

Leave a Reply

Your email address will not be published. Required fields are marked *