Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Error 2042 problem with vlookup

I'm having a problem trying to use a simple vlookup request and match it to
another variable.

Two tables on two sheets. The problem I'm having is that when the vlookup
request to the array comes back as an error when it shouldn't. I've looked
at this code 100 times and I can't find an error. Any help??

Sheet1
501 Description A
502 Description B
503 Description C
504 Description D

Sheet2
500 5/16/2011 TEST0
500 5/16/2011 TEST1
500 5/16/2011 TEST2
501 5/16/2011 TEST3
503 5/16/2011 TEST4
503 5/16/2011 TEST5
504 5/16/2011 TEST6

Here is my code:

Sub KeepTrying()

Sheets("Sheet2").Activate
'Get Count
Range("A1").Select
i = 0
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Select
i = i + 1
Loop

'Create Array using count
Dim tableA() As Variant
ReDim tableA(1 To i, 1 To 3)
Range("A1").Select
x = 1
Do Until x = i + 1
tableA(x, 1) = ActiveCell.Offset(0, 0).Value
tableA(x, 2) = ActiveCell.Offset(0, 1).Value
tableA(x, 2) = ActiveCell.Offset(0, 2).Value
ActiveCell.Offset(1, 0).Select
x = x + 1
Loop

'Check
Sheets("Sheet1").Activate
Range("A1").Select
Do Until ActiveCell.Value = ""
For d = 1 To i
code = ActiveCell.Value
codeCheck = Application.VLookup(d, tableA, 1, False) - PROBLEM!!!
If code = codeCheck Then
ActiveCell.Offset(0, 3).FormulaR1C1 = "Y"
ActiveCell.Offset(1, 0).Select
End If
Next
Loop

End Sub

----------------
Chat Bot mIRC://bezerk.ath.cx
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vlookup error in VBA, 2042 elf27 Excel Programming 4 March 15th 09 01:39 AM
error 2042 with vlookup Bert Excel Programming 6 February 16th 09 05:52 PM
Error 2042 Fred Excel Programming 1 June 21st 08 12:20 AM
vlookup error 2042 jer Excel Programming 0 November 27th 06 02:31 PM
Error 2042 Barbara[_3_] Excel Programming 1 September 8th 03 08:16 PM


All times are GMT +1. The time now is 06:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"