#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Vlookup

Good morning. I use the following function to fill each cell in column 20.

VLOOKUP(B2,MSC.xls!$A$2:$C$322,3,FALSE)


This works great, but I need to turn it into VBA code. The B2 would have to
increment for each cell (i.e. B2, B3, B4, B5... etc) until the last row was
completed.

Thanks Bill
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Vlookup

Hi Bill
not tested but HTH

Sub VlookupFill()

Range("T2").FormulaR1C1 = "=VLOOKUP(RC2,MSC.xls!R2C1:R[320]C3,3,FALSE)"
Range("T2").AutoFill Destination:=Range("T2:T" & Range("B2:B10000").End
_(xlUp).Row)

End Sub

--
Regards
Aussie Bob C.

"Bill" wrote:

Good morning. I use the following function to fill each cell in column 20.

VLOOKUP(B2,MSC.xls!$A$2:$C$322,3,FALSE)


This works great, but I need to turn it into VBA code. The B2 would have to
increment for each cell (i.e. B2, B3, B4, B5... etc) until the last row was
completed.

Thanks Bill

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Vlookup

I tried it. It did not work for my sheet. Thanks for your help.

"Robert Christie" wrote:

Hi Bill
not tested but HTH

Sub VlookupFill()

Range("T2").FormulaR1C1 = "=VLOOKUP(RC2,MSC.xls!R2C1:R[320]C3,3,FALSE)"
Range("T2").AutoFill Destination:=Range("T2:T" & Range("B2:B10000").End
_(xlUp).Row)

End Sub

--
Regards
Aussie Bob C.

"Bill" wrote:

Good morning. I use the following function to fill each cell in column 20.

VLOOKUP(B2,MSC.xls!$A$2:$C$322,3,FALSE)


This works great, but I need to turn it into VBA code. The B2 would have to
increment for each cell (i.e. B2, B3, B4, B5... etc) until the last row was
completed.

Thanks Bill

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Vlookup

Good morning. I use the following function to fill each cell in column 20.

VLOOKUP(B2,MSC.xls!$A$2:$C$322,3,FALSE) 'The B2 would have to increment


This works great, but I need to turn it into VBA code. The B2 would have to
increment for each cell (i.e. B2, B3, B4, B5... etc) until the last row was
completed.

Thanks Bill

"Bill" wrote:

Good morning. I use the following function to fill each cell in column 20.

VLOOKUP(B2,MSC.xls!$A$2:$C$322,3,FALSE)


This works great, but I need to turn it into VBA code. The B2 would have to
increment for each cell (i.e. B2, B3, B4, B5... etc) until the last row was
completed.

Thanks Bill

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Vlookup

How do you know that last cell in column T--from looking at column A????

dim LastRow as long
with worksheets("sheet1")
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("t2:t" & lastrow).formula = "=vlookup(b2,msc.xls!$a$2:$c$322,3,false)"
end with

(First cell to get the formula is T2???)

Is Msc.xls a worksheet name?

If yes, then that's kind of weird. If no, then where's the worksheet name in
your formula?

I'd get that formula working manually, then copy it into my code.

Bill wrote:

Good morning. I use the following function to fill each cell in column 20.

VLOOKUP(B2,MSC.xls!$A$2:$C$322,3,FALSE)

This works great, but I need to turn it into VBA code. The B2 would have to
increment for each cell (i.e. B2, B3, B4, B5... etc) until the last row was
completed.

Thanks Bill


--

Dave Peterson
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
If (Vlookup 0) working, but what if Vlookup cell does not exist Steve Excel Worksheet Functions 18 November 18th 09 07:33 PM
VLookUp - Does the VLookUp return the exact information? Cpviv Excel Worksheet Functions 2 October 28th 08 09:57 AM
Vlookup in vlookup - taking the result as array name SupperDuck Excel Worksheet Functions 2 June 2nd 07 11:05 AM
Combine VLOOKUP and IF function so #NA isn't returned as a value from VLOOKUP buffgirl71 Excel Discussion (Misc queries) 12 November 14th 06 11:36 PM
Vlookup -=VLOOKUP(F9,LookUp1!$A$2:$B$1504,2,FALSE) MikeR-Oz New Users to Excel 1 March 22nd 06 09:01 AM


All times are GMT +1. The time now is 11:04 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"