LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Please help.. VLookup Macro

Rich,

First a mild caution - Please don't attach anything to your message. People
won't touch it and you won't get many replies - if any...

Now - the code I might use might look like this:

Dim cel as Range, rng1 as Range, rng2 as Range, rng3 as range

Set rng1 = Workbooks("MyBook").Worksheets("VENTURE").Range("A 10:50")
Set rng2 = Workbooks("C:\VRMList.xls").Worksheets("VRM
BYNUMBER").Range("B3:C140")
Set rng3 = Workbooks("C:\VRMList.xls").Worksheets("VRM
BYNUMBER").Range("B:B")

For each cel in rng1
If worksheetfunction.Countif(rng3,cel) 0 then
cel = WorksheetFunction.Vlookup(cel,rng2,2,False)
else
msgbox "Product Code not found"
End If
Next

--
steveB

Remove "AYN" from email to respond
"Rich Foreman" wrote in message
...
Hi,

I have two workbooks. One is the one the macro needs to be run on, but
it needs to get data from another workbook.

One worksheet 1, We have a list of our forumulas. To protect ourselves,
these only use the product code in column A, and not the product name.

On workbook 2, we have a list of product codes in column B and column C
is the products name.

Out office manager wants to print out workbook 1, but first he wants the
product code replaced with the product name.

Here is what I tried so far, but I get an error in this code:

Sub ReplaceVRMWithName()

Dim r1 As Range
Dim x As Long

Set r1 = Workbooks("C:\VRMList.xls").Worksheets("VRM BY
NUMBER").Range("B3:C140")

(In that, I am trying to open up the second workbook and get the list of
product codes and names into a range. this is where my error is
currently)

For x = 10 To 50
With Worksheets("VENTURE")
.Range("A" & x).Value = Application.VLookup( _
.Range("A" & x), r1, 2, False)
End With
Next

(here, I am trying to replace the product codes in workbook 1 with the
product name. THe codes are in cells A10 - A50. Is this how I am
supposed to do this?)

End Sub

*** Sent via Developersdex http://www.developersdex.com ***



 
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
VLOOKUP Macro? blucajun Excel Worksheet Functions 3 June 30th 08 09:54 PM
Macro - Vlookup orquidea Excel Discussion (Misc queries) 6 May 14th 08 04:42 PM
Vlookup Macro Joey Excel Discussion (Misc queries) 0 April 11th 08 02:36 AM
Vlookup Macro? ctwobits Excel Discussion (Misc queries) 0 December 6th 07 09:42 PM
Need a macro to do what this VLOOKUP does Tim Excel Programming 5 February 12th 04 04:41 PM


All times are GMT +1. The time now is 06:59 AM.

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

About Us

"It's about Microsoft Excel"