Solved

Vlookup error

Posted on 2012-03-27
5
300 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 33

Accepted Solution

by:
Norie earned 500 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 10

Expert Comment

by:JEaston
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
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…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

762 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now