![]() |
|
|
|||||||
| FlashChat | Actuarial Discussion | Preliminary Exams | CAS/SOA Exams | Cyberchat | Around the World | Suggestions |
Entry Level |
DW Simpson
& Co. |
Casualty Jobs |
Salary Surveys |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I am having a problem with the following line of code in VBA:
If Application.WorksheetFunction.VLookup(Cells(i, 26), Range(Cells(4, 3), Cells(lastRCap, 3)), 1, False) = "123" Then I am getting an error message that says: "Application-defined or object-defined error". Could somebody help me out; I am somewhat of a beginner in using VBA. |
|
#2
|
|||
|
|||
|
Try using "cell" instead of "cells".
Unless that was just a typo. |
|
#4
|
||||
|
||||
|
I ran this snippet of code through VBA and it worked just fine. However, you get the error you've described if the variables i and lastRCap are not defined.
__________________
Outposter 3.14 is a generally awesome person, and a servicible approximation to pi. This message subject to change. |
|
#5
|
|||
|
|||
|
lastRCap is the # of rows in the list, and yes, there is really a match that is numeric.
I don't know if it matters, but it is in a for loop, I tried changing Cells to 'Cell' as per Tyger's suggestion but that just gave a compile error. Here is the whole bit of code I'm using it in: For i = 2 To lastRSource If Application.WorksheetFunction.VLookup(Cells(i, 26), Range(Cells(4, 3), Cells(lastRCap, 3)), 1, False) = "123" Then Range("A1") = 123 End If Next i |
|
#6
|
|||
|
|||
|
Hmm..I don't think I changed anything, but when I run it now, I am getting an error saying: "Unable to get the VLookup property of the WorksheetFunction class"
|
|
#7
|
|||
|
|||
|
Sorry, ignore the last post about the "Unable to get the VLookup property of the WorksheetFunction class" error; that was a result of something I commented out by mistake.
|
|
#9
|
|||
|
|||
|
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|