Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to copy related information from sheet 1 to sheet 2 dave Excel Worksheet Functions 1 December 5th 09 02:00 AM
Matching rows in 2 sheets and copying matching rows from sheet 1 t fbagirov Excel Programming 1 April 8th 07 03:44 PM
Copying related information between worksheets Ingrid Excel Discussion (Misc queries) 1 October 24th 06 06:43 PM
problem of copying column related to date news Excel Discussion (Misc queries) 3 May 12th 06 10:23 PM
how am i able to store a number as text? (ADO related) Beth[_5_] Excel Programming 1 March 3rd 04 01:44 PM


All times are GMT +1. The time now is 08:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"