Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vlookup macro in excel

I need some help with a simple macro. I need it to spin thru all the rows of
Sheet B, do a vlookup using project number to pick up project name from Sheet
A, and place the project name in Sheet B.

Sample information:

Sheet A - Project Overview
Col A = Project Number (lookup field, match with Sheet B, Col D)
Col B = Project Name (to be copied to Sheet B MoProject Name after the
macro is run)

Sheet B - Monthly Project Details

Col D = MoProject Number (lookup field - match with Sheet A, Col A)
Col E = MoProject Name (empty prior to the macro being run, contains
Project Name from Sheet A after macro is run)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default vlookup macro in excel

Use worheetfunction.vlookup() when you are not looking for an exact amtch.
In your case where you are looking for exact matches then use find.

with sheets("Sheet B")
RowCount = 1
Do while .Range("D" & RowCount) < ""
ProjNum = .Range("D" & RowCount)
with sheets("Sheet A")
set c = .Columns("A").find(what:=ProjNum,lookin:=xlvalues,
lookat:=xlwhole)
end with
if not c is nothing then
.Range("D" & RowCount) = c.offset(0,1)
end if
RowCount = RowCount + 1
loop
end with

"Midwest-Lisa" wrote:

I need some help with a simple macro. I need it to spin thru all the rows of
Sheet B, do a vlookup using project number to pick up project name from Sheet
A, and place the project name in Sheet B.

Sample information:

Sheet A - Project Overview
Col A = Project Number (lookup field, match with Sheet B, Col D)
Col B = Project Name (to be copied to Sheet B MoProject Name after the
macro is run)

Sheet B - Monthly Project Details

Col D = MoProject Number (lookup field - match with Sheet A, Col A)
Col E = MoProject Name (empty prior to the macro being run, contains
Project Name from Sheet A after macro is run)

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
using a vlookup command in a for next loop in a macro in excel Amethyst Excel Programming 5 March 17th 07 08:13 PM
using a vlookup command in a for next loop in a macro in excel Amethyst Excel Discussion (Misc queries) 3 March 17th 07 01:30 PM
Excel macro/function like VLOOKUP that sums eventual multiple matches Mary[_10_] Excel Programming 2 May 30th 06 04:22 PM
Please help.. VLookup Macro STEVE BELL Excel Programming 3 August 3rd 05 05:31 PM
Excel Macro for VLookup Function app_trainer Excel Programming 0 January 16th 04 04:31 PM


All times are GMT +1. The time now is 11:40 AM.

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"