Vlookup issues VBA

liam-the-1-n-only

New Member
Joined
Oct 14, 2013
Messages
4
Good Morning All

Any help with this issue would be greatly appreciated, i cannot seem to figure out why this wont work..?

Code:
Dim refcell As String
Dim Location As String
Dim excelname As String
Dim ext As String
Dim r As String
Dim lookuprange As String
Dim cs As Integer
Dim Boo As Boolean
Dim Row As Integer


Row = ActiveCell.Row
refcell = "$A" & Row
Location = "'D:\Documents and Settings\*****\Desktop\vb excel\testing docs\"
Name = "[" & Format(Date, "dd.mm.yy")
ext = ".xlsx]"
excelname = Name & ext
r = "Sheet1'!$A:$AS"
lookuprange = Location & excelname & r
cs = 40
Boo = False

If i do the below i get , "unable to get vlookup property of worksheetfunction class"

Code:
ActiveCell.Value = Application.WorksheetFunction.VLookup("refcell", "lookuprange", "cs", "Boo")

If i do this ;
Code:
ActiveCell.Formula = "=VLookup(refcell, lookuprange, cs, Boo)"

i get this in the relevant cell, =VLOOKUP(refcell, lookuprange, cs, Boo)

this issue has been causing me hours of headaches and forum posting to no provale so any help would be GREAT!

Thanks
Liam
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try

Code:
ActiveCell.Value = Application.VLookup(refcell, lookuprange, cs, Boo)
 
Upvote 0
Welcome to the board. I'd go for something like this:
ActiveCell.Formula = "=VLOOKUP(" & refcell & "," & lookuprange & "," & cs & "," & Boo & ")"
 
Upvote 0
just to add to the situation as well if i remove the file location it works :/ but only if i move the file to the relative folder location so it seems as if the location string is what is screwing it up, hope this helps..
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top