vlookup + macro that doesn't overrwrite old data--need help

amandabstewart

New Member
Joined
Aug 4, 2014
Messages
45
My workbook uses both vlookup (price lists) and macros that update a log when I run it.
For example, cost of item A is $10 currently. Using vlookup, prices from the price sheet are entered automatically on a sales sheet. I run the macro that takes that sale info and copies parts of the row to a worksheet for who made the sale—eg Alex’s page would now say $10.
The problem is that if we change the prices on the price sheet and re-run the macro periodically to update new sales, eg cost of item A is changing to $15, it automatically changes the OLD $10 sale to the new value and Alex’s old sales would read $15. I don’t want it to overwrite the old data when I update the price sheet.
Is there a way to either:
- Make excel leave the old vlookup value in the sales sheet once a sale is made and NOT update the price on later sales (doubt this is possible)
- OR, make the macro not overwrite old data.
I really need it to leave the sales page alone too, and my old option was to have the world’s longest nested IF statement. That won’t work for the people who will use this workbook…they are basic users w/o ability to change something that complicated.
How can I make the sales entry page be “final’?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hiya
Are you looping through the entire sales sheet each time the macro runs?
If so, how about storing the number of used rows within the sales sheet each time, & then use that for the loop eg
Code:
    UsdRws = Range("A" & Rows.Count).End(xlUp).Row
    
    For i = Range("A1").Value To UsdRws
'    ...
'    ...
    Next i


    Range("A1") = Range("A1") + UsdRws
HTH
 
Upvote 0
Can you further explain your reply? It would look through the price list each time...for example, we would do data entry of the sales (say, 10 entries) and then run the macro...which should copy the info over to the individual's page (which it does correctly), but, if I change prices and re-run it, it overwrites the old sales $ the individual earned. When we enter the data, it would likely be 10 entries belonging to 10 different individuals.
Does that clarify? I'm still somewhat new to VBA...trying to learn


Would I copy the code you provided at the end of current macro?
 
Upvote 0
Hiya
Kindly disregard the code I posted before, not sure what I was doing.
Best bet is if you could post your code & I'll show you how to change it.
 
Upvote 0

Forum statistics

Threads
1,214,886
Messages
6,122,093
Members
449,064
Latest member
Danger_SF

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top