Thread: VLOOKUP and VBA
View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default VLOOKUP and VBA

I needed to make a change so as to use a different target. This is what I have:

CompanyID = Application.WorksheetFunction.VLookup("R" & Target.Row & "C" &
(Target.Column + 1),
Sheets("Statics").Range("Query_from_MS_Access_Data base"), 2, False)

basically, I want to do a lookup of the data that is one column to the right
of the cell that is changed.

I think my problem is that my first lookup argument is the location of the
value to lookup, not what's being checked (R3C5, not "Company1"). I'd put
in indirect, but this won't work. Suggestions?

Barb Reinhardt

Thanks,
Barb
"John" wrote:

Glad you're sorted. Apologies for the red herring!

Have a good weekend

John

"Barb Reinhardt" wrote in message
...
I figured out what I needed.

CompanyID = Application.WorksheetFunction.VLookup(Target,
Sheets("Statics").Range("Query_from_MS_Access_Data base"), 2, False)


"John" wrote:

Hi Barb,

Do you need the WorksheetFunction object in there?

ie "Application.WorksheetFunction.VLookup(......"

Best regards

John

"Barb Reinhardt" wrote in
message
...
I thought I posted this, but I can't find it now so it's possible it
never
was posted. If it's a duplicate, my apologies.

I have the following equation that's not working and I'm not sure why

CompanyID = Application.VLookup(Target, Range("Statics
Query_from_MS_Access_Database"), 2, False)

I get
runtime error 1004.
Method 'range' of object '_worksheet' failed

I have a named range of Query ... on the Statics worksheet.

Thanks,
Barb Reinhardt