PDA

View Full Version : Copy Prices (with conditions - VBA) from one workbook to another



stt01029
04-12-2011, 08:34 AM
Hi all,

I am quite new to VBA and I assume my problem should be particularly easy for the average programmer.

I have two workbooks containing prices - with the format below

date - price 1 - price 2 - etc

I am updating daily the one of the two and I am trying to set up a vba code that copies and pastes automatically all the new prices from the first workbook to the second.

I assume that the main condition here is to match the date horizontally and the name of the price vertically and creat a loop - unfortunately I can't do it on my own - could someone help on that??

Thank you in advance!

BrianMH
04-12-2011, 09:32 AM
can you post a copy of some data?

stt01029
04-12-2011, 09:45 AM
Hi Brian,

Thanks for the quick response on that.

Please find attached a file example - I hope it makes sense.

Thanks again,

Michael

BrianMH
04-12-2011, 09:56 AM
instead of doing any vba I would just use a vlookup referencing the worksheet. You can even use a path so it doesn't need to be open.

=VLOOKUP(A1,'C:\[2ndworkbookname.xls]Sheet1'!$A$1:$D$65536,2,FALSE)

stt01029
04-12-2011, 10:35 AM
Thank you once again for your help - really appreciated.

I had that in mind when I started playing around, but I was worried about potential changes in columns/lines from other users.

That's why I was trying to come up with sth that looks at the date horizontally and the price name vertically and adds the right price in the right cell irrespectivelly of what the users are doing.

However, I will use the easy way as you suggested, since many times the simple is much better!

Thanks once again