Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Matching a number from another sheet and copying a related value
Hi all,
I'm pretty new to the VB world and have a macro question. I'm trying to take a part number from one database in excel and then search for the matching part number in a different workbook. Once that value is matched or found, then I need to copy the price of that part back to the orginal excel sheet. This needs to be done for multiple part numbers, well until it hits a blank. I have tried a few things, but I just can't get it right. My problem is how to move to the next cell and select the price cell once the part number is found. Does anyone have some example code to do this? Anything would help. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Matching a number from another sheet and copying a related value
This sub looks for three part numbers. There is no error handler if the part
numbers can't be found, but it should give you a start: Sub fetchit() partnumber = Array(100, 101, 102) For i = 0 To 2 pn = partnumber(i) Windows("database.xls").Activate For j = 1 To 1000 If Cells(j, "A").Value = pn Then Cells(j, "B").Copy Exit For End If Next Windows("original.xls").Activate Cells(i + 1, "A").Select ActiveSheet.Paste Next End Sub -- Gary''s Student - gsnu200761 "Heldy" wrote: Hi all, I'm pretty new to the VB world and have a macro question. I'm trying to take a part number from one database in excel and then search for the matching part number in a different workbook. Once that value is matched or found, then I need to copy the price of that part back to the orginal excel sheet. This needs to be done for multiple part numbers, well until it hits a blank. I have tried a few things, but I just can't get it right. My problem is how to move to the next cell and select the price cell once the part number is found. Does anyone have some example code to do this? Anything would help. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formula to copy related information from sheet 1 to sheet 2 | Excel Worksheet Functions | |||
Matching rows in 2 sheets and copying matching rows from sheet 1 t | Excel Programming | |||
Copying related information between worksheets | Excel Discussion (Misc queries) | |||
problem of copying column related to date | Excel Discussion (Misc queries) | |||
how am i able to store a number as text? (ADO related) | Excel Programming |