Vlookup Date

mezzy01

Board Regular
Joined
Nov 7, 2005
Messages
54
Help required. I've got a date in Sheet 1 A1 that I'm looking up in Sheet b. The date is in the column but the lookup fails to recognise it.

Any ideas, pls

Sub Example_of_Vlookup()
Dim lookFor As Range
Dim rng As Range
Dim col As Integer
Dim found As Variant

Set lookFor = Sheets("Sheet1").Range("A1")
Set rng = Sheets("b").Columns("A:B")
col = 2

On Error Resume Next
found = Application.WorksheetFunction.VLookup(lookFor.Value, rng, col, 0)
If IsError(found) Then
MsgBox lookFor & " not found"
Else: MsgBox "The look-up value of " & lookFor & " is " & found & " in column " & col
End If
On Error GoTo 0
End Sub
 

Superstar31

Active Member
Joined
Nov 10, 2005
Messages
496
why does everyone use macros? when you can make a formula to achieve the same thing?
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
9,999
This works for me in testing. I'd check your data types (formats). One may be text while the other is general. You can use Data|Text to Columns... to coerce them into identical formats if this is the case.
 

Forum statistics

Threads
1,077,783
Messages
5,336,306
Members
399,074
Latest member
rlong98

Some videos you may like

This Week's Hot Topics

Top