Thursday, December 15, 2011

Excel how to transfer a row of details to another worksheet by typing in a unique ID using a macro?

ok i am currently doing a till system for Ict coursework i am doing it on excel (because it is required) and i require help with macros


What i currently have is a database of items





Sheet 1





Unique Id | Items Name: | Item Price | Stock





1001 | Dairy milk | 拢0.40 | 15


1002 | Fanta | 拢0.80 | 20


Etc





on Sheet 2





Unique Id | Items Name: | Item Price | Stock





i have this


but with no details in it


what i want is to be able to copy a product from the database to the data base in the sheet 2





By typing in a cell the unique id and then pressing a command button saying Add





This automatics copys and pastes the unique id the item and price and stock into the sheet 2.





Then i require the cell that i typed into to be cleared once i pressed the add button so another product can be brought





after that i require finsh button which then transfers the the total profit and minus the stock made from that sale into another worksheet|||Rather than programming a macro, try using the VLOOKUP() function. I'm assuming that the phrase "Unique ID" appears in cell A1 on both sheets (thus leaving your headers in row 1, with the info in columns A through D), so you may need to adjust if that's not the case.





In cell B2 on Sheet 2, type the following formula:





=IF($A2="","",VLOOKUP($A2,


'Sheet1'!$A:$D,COLUMN(),


FALSE))





Now copy/paste this formula into cells C2 and D2, as well.


You can also paste this into B3-D3, B4-D4, etc. to utilize more than one row.





Now, when you type the Unique ID number into cell A2, the rest of the information should automatically populate.





Then you should be able to calculate the profits from sale with simpler formulas.

No comments:

Post a Comment