Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Vlookup error

Posted on 2012-03-27
5
Medium Priority
?
313 Views
Last Modified: 2012-03-27
Hi,

Im getting a syntax error on the below lookup i have created

Can anyone advise why this is so?

Thanks
Seamus





Function test()
Dim Res As Variant
Dim r As Long

r = ActiveCell

Res = Application.WorksheetFunction.VLookup(r,Phoenix Pivot!',A:A,1, 0)


End Function
0
Comment
Question by:Seamus2626
5 Comments
 
LVL 11

Expert Comment

by:Runrigger
ID: 37771696
Phoenix Pivot!',A:A

should be

'Phoenix Pivot'!A:A
0
 

Author Comment

by:Seamus2626
ID: 37771764
Still getting a Syntax error

Seamus

Function test()
Dim Res As Variant
Dim r As Long

r = ActiveCell

Res = Application.WorksheetFunction.VLookup(r,'Phoenix Pivot'!A:A,1, 0)


End Function
0
 
LVL 35

Accepted Solution

by:
Norie earned 2000 total points
ID: 37771786
Try this.
Res = Application.WorksheetFunction.VLookup(r.Value,Worsheets("Phoenix Pivot").Range("A:A"),1, 0)

Open in new window

0
 
LVL 11

Expert Comment

by:John Easton
ID: 37771788
The bit A:A,1 will generate an error.  Normally you would have a cell reference, e.g:  A1:A10.
0
 

Author Closing Comment

by:Seamus2626
ID: 37771833
Thats the one,

Thanks
Seamus
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question