Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help to Compare New Sheet to Master and Update

Status
Not open for further replies.
Mar 23, 2015
37
US
It's been a quite awhile since I had to do any VBA, but I have a new project.

There is a master.xlsx with all the data on it.
Each month the user downloads a new batch of data.
1. I need to compare the "Subscriber" columns (value is lastname, firstname) of the new.xls to the master.xlsx to determine new "Subscribers" and ADD them to the master.xlsx. (The original data did contain a unique id but that's been removed on the master list. I might have to go back in and have it re-entered by hand and then compare by that column)
4. I need to compare the "Subscriber" columns and "Amount" column and if the "Amount" has changed then change it on the master.xlsx.


If anyone can get me started I'd appreciate it. In the few things I've needed to do I've never had to compare stuff so that's new.

Thanks!
 
Assuming all columns in new.xlsx match all columns in master.xlsx (number and order), and master.xlsx contains just one sheet (let’s call it Master), I would create a sheet2 in master.xlsx, copy all data from new.xlsx to that new sheet (let’s name it New). And now we deal with just one file/workbook with 2 sheets.
Also assuming all “Subscribers” in Master are unique and all “Subscribers” in New are unique

Code:
Read a row from New, grab “Subscribers” 
Look for “Subscribers” in Master
If found
    If Master.Amount <> New.Amount then
        Master.Amount = New.Amount
    End If
Else if not found
    Add the row from New to Master
End If

I'm sure there is another, better way. :)

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top