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: 41
Default VBA/Vlookup with workbook defined in a variable

I have this as my code:
Workbooks("Auto Model Grid").Worksheets("Sheet1").Activate
With ActiveSheet

For counter = 2 To 55
Set mycell = Worksheets("Sheet1").Cells(counter, 12)

lval = mycell
If lval = "CCS" Then
If ccsfile = "yes" Then
mycell.Offset(counter, 14).Value =
Application.Worksheet.VLookup("CCS" & dlrrep,
Sheets("SMART").Range("$A$2:$H$82"), 7, 0)
End If

ElseIf lval = "DCS" Then
If dcsfile = "yes" Then
mycell.Offset(counter, 14).Value =
Application.WorksheetFunction.VLookup("DCS" & dlrrep,
Sheets("SMART").Range("$A$2:$H$82"), 7, 0)
End If
End If
Next counter
End With

For some reason when I do the vlookup I am getting an error message saying
the subscript is out of range. Is this because I am in another workbook that
it can't do the lookup on the other workbook or is it because I am trying to
string together a string plus a variable as the workbook's name? Any
thoughts would be welcome.
Thanks again in advance.
Heather O
 
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
Variable sum from defined input David Excel Worksheet Functions 7 March 10th 09 06:26 AM
Vlookup using a variable for the workbook name Phil Excel Discussion (Misc queries) 4 November 10th 08 09:30 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
[Q] msoShapeRectangle: variable not defined Rolf Marvin Bøe Lindgren Excel Programming 0 May 12th 04 09:00 AM
Problem with a defined variable ric Excel Programming 2 April 26th 04 08:42 PM


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

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"