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

I am trying to captures the contents of a field in a worksheet based on the
value of a field in a different worksheet. This field will become the To
list in an email message but I am receiving an error in the Vlookup function:

Dim CCList As String
Dim tmplist As String
Dim LkRange As Range

Set LkRange = Worksheets("Contact List").Range("A2:F25")
If Sheets("Hold Reasons").Range("C28") = "X" Then
tmplist = Application.WorksheetFunction.VLookup(D6, LkRange, 2, False)
CCList = CCList + tmplist
End If

The above code generates the error "Run Time Error 1004; Unable to get the
Vlookup property of the Worksheet Function class" on the Vlookup line. When
stepping through this code LkRange has no value so the failure appears to be
in capturing the range. I tried putting the range directly into the Vlookup
function and that generated syntax errors.

Any help would be appreciated!
Marnie
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Vlookup Error

You may still have a problem. If the value in D6 doesn't match anything in
A2:A25 of Contact list, you'll get the same error.

I'd use:

Dim CCList As String
Dim tmplist As Variant 'could return an error
Dim LkRange As Range

Set LkRange = Worksheets("Contact List").Range("A2:F25")
If Sheets("Hold Reasons").Range("C28") = "X" Then
'dropped the .worksheetfunction portion
tmplist = Application.VLookup(somesheet.range("D6"), LkRange, 2, False)
if iserror(tmplist) then
tmplist = 0
end if
CCList = CCList + tmplist
End If

I'd qualify where D6 is located, too.

Marnie wrote:

I am trying to captures the contents of a field in a worksheet based on the
value of a field in a different worksheet. This field will become the To
list in an email message but I am receiving an error in the Vlookup function:

Dim CCList As String
Dim tmplist As String
Dim LkRange As Range

Set LkRange = Worksheets("Contact List").Range("A2:F25")
If Sheets("Hold Reasons").Range("C28") = "X" Then
tmplist = Application.WorksheetFunction.VLookup(D6, LkRange, 2, False)
CCList = CCList + tmplist
End If

The above code generates the error "Run Time Error 1004; Unable to get the
Vlookup property of the Worksheet Function class" on the Vlookup line. When
stepping through this code LkRange has no value so the failure appears to be
in capturing the range. I tried putting the range directly into the Vlookup
function and that generated syntax errors.

Any help would be appreciated!
Marnie


--

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
vlookup error Jim Excel Worksheet Functions 1 January 25th 06 08:49 PM
VLOOKUP error Eintsein_mc2 Excel Discussion (Misc queries) 2 September 17th 05 07:12 AM
Vlookup Error MJRay Excel Programming 3 March 8th 05 09:19 PM
Vlookup Error mick.smith1964 Excel Worksheet Functions 5 January 13th 05 10:03 PM
vlookup error Josh O. Excel Worksheet Functions 6 December 30th 04 05:16 PM


All times are GMT +1. The time now is 05:32 PM.

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"