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: 21
Default vlookup in vba code

Hello,
I am trying to use Vlookup in Excel VBA. I have two sheets in my workbook
which is called "Validation Macro.xls" . I want to do a lookup based on a
cell's value in the first sheet. The lookup range is in the second sheet
called "TLA". I am trying to do this with the code below. Only the first line
gives me the following error: "Runtime error 9 - Subscript out of range".
Would anyone have any suggesions on how to properly do this? Thanks in
advance!


Set wb = Workbooks("C:\Documents and Settings\Sharon\MyDocuments\Validation
Macro.xls")
Set ws = wb.Sheets("TLA")
Set rng = ws.Range("A2:D15")

ActiveCell.Value =
Application.WorksheetFunction.VLookup(ActiveCell.O ffset(0, -31).Value, rng,
3, False)

 
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 as a vb code Tdp Excel Discussion (Misc queries) 5 November 25th 08 10:01 PM
Using VLOOKUP in VBA code Mark Excel Worksheet Functions 2 August 18th 06 04:41 PM
what is the VBA code for VLOOKUP? Shan Excel Programming 2 March 3rd 05 02:53 PM
Using Vlookup in VBA code Kathy - Lovullo Excel Programming 2 December 29th 04 06:39 PM
Help with Vlookup code Gareth[_3_] Excel Programming 0 November 19th 03 07:28 PM


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