Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default VLOOKUP error 1004

Hi,

Can anyone help me to find the error in this code?

Private Sub btn4_Click()
Dim magneto As Range
Dim numero
Dim valor
Set magneto = Worksheets("info").Range("A2:AW65536")
numero = ufConsulta.txt33.Value
ufConsulta.cbo1.Value = Application.WorksheetFunction.VLookup(numero,
magneto, 13, false)

Thanks in advance...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VLOOKUP error 1004

Drop the .worksheetfunction portion:

ufConsulta.cbo1.Value = Application.VLookup(numero, magneto, 13, false)



Omar wrote:

Hi,

Can anyone help me to find the error in this code?

Private Sub btn4_Click()
Dim magneto As Range
Dim numero
Dim valor
Set magneto = Worksheets("info").Range("A2:AW65536")
numero = ufConsulta.txt33.Value
ufConsulta.cbo1.Value = Application.WorksheetFunction.VLookup(numero,
magneto, 13, false)

Thanks in advance...


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default VLOOKUP error 1004

I tried it and the same error message is still there.

"Dave Peterson" wrote:

Drop the .worksheetfunction portion:

ufConsulta.cbo1.Value = Application.VLookup(numero, magneto, 13, false)



Omar wrote:

Hi,

Can anyone help me to find the error in this code?

Private Sub btn4_Click()
Dim magneto As Range
Dim numero
Dim valor
Set magneto = Worksheets("info").Range("A2:AW65536")
numero = ufConsulta.txt33.Value
ufConsulta.cbo1.Value = Application.WorksheetFunction.VLookup(numero,
magneto, 13, false)

Thanks in advance...


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VLOOKUP error 1004

I'd use:

Private Sub btn4_Click()
Dim magneto As Range
Dim numero
Dim valor
dim res as variant
Set magneto = Worksheets("info").Range("A2:AW65536")
numero = ufConsulta.txt33.Value
res = Application.VLookup(numero, magneto, 13, false)
if iserror(res) then
ufConsulta.cbo1.Value = "No match"
else
ufConsulta.cbo1.Value = res
end if
....

====
One more thing to watch out for...
If you're matching up numbers (not text), you may want:
res = Application.VLookup(cdbl(numero), magneto, 13, false)
or
res = Application.VLookup(clng(numero), magneto, 13, false)



Omar wrote:

I tried it and the same error message is still there.

"Dave Peterson" wrote:

Drop the .worksheetfunction portion:

ufConsulta.cbo1.Value = Application.VLookup(numero, magneto, 13, false)



Omar wrote:

Hi,

Can anyone help me to find the error in this code?

Private Sub btn4_Click()
Dim magneto As Range
Dim numero
Dim valor
Set magneto = Worksheets("info").Range("A2:AW65536")
numero = ufConsulta.txt33.Value
ufConsulta.cbo1.Value = Application.WorksheetFunction.VLookup(numero,
magneto, 13, false)

Thanks in advance...


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default VLOOKUP error 1004

If I'm expecting a String value, should I use:
res = Application.VLookUp(CStr(numero), magneto, 13, false)
?

Regards...

"Dave Peterson" wrote:

I'd use:

Private Sub btn4_Click()
Dim magneto As Range
Dim numero
Dim valor
dim res as variant
Set magneto = Worksheets("info").Range("A2:AW65536")
numero = ufConsulta.txt33.Value
res = Application.VLookup(numero, magneto, 13, false)
if iserror(res) then
ufConsulta.cbo1.Value = "No match"
else
ufConsulta.cbo1.Value = res
end if
....

====
One more thing to watch out for...
If you're matching up numbers (not text), you may want:
res = Application.VLookup(cdbl(numero), magneto, 13, false)
or
res = Application.VLookup(clng(numero), magneto, 13, false)



Omar wrote:

I tried it and the same error message is still there.

"Dave Peterson" wrote:

Drop the .worksheetfunction portion:

ufConsulta.cbo1.Value = Application.VLookup(numero, magneto, 13, false)



Omar wrote:

Hi,

Can anyone help me to find the error in this code?

Private Sub btn4_Click()
Dim magneto As Range
Dim numero
Dim valor
Set magneto = Worksheets("info").Range("A2:AW65536")
numero = ufConsulta.txt33.Value
ufConsulta.cbo1.Value = Application.WorksheetFunction.VLookup(numero,
magneto, 13, false)

Thanks in advance...

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VLOOKUP error 1004

The value in that text box (ufconsulta.txt33 is a textbox, right?) is already a
string. So cstr() won't help at all.

But I would declare my variables more explicitly if I knew what they we

dim numero as String
dim Valor as ????????

res is declared as a variant because it could be a number (long or double), a
string, but especially since it could be an error.



Omar wrote:

If I'm expecting a String value, should I use:
res = Application.VLookUp(CStr(numero), magneto, 13, false)
?

Regards...

"Dave Peterson" wrote:

I'd use:

Private Sub btn4_Click()
Dim magneto As Range
Dim numero
Dim valor
dim res as variant
Set magneto = Worksheets("info").Range("A2:AW65536")
numero = ufConsulta.txt33.Value
res = Application.VLookup(numero, magneto, 13, false)
if iserror(res) then
ufConsulta.cbo1.Value = "No match"
else
ufConsulta.cbo1.Value = res
end if
....

====
One more thing to watch out for...
If you're matching up numbers (not text), you may want:
res = Application.VLookup(cdbl(numero), magneto, 13, false)
or
res = Application.VLookup(clng(numero), magneto, 13, false)



Omar wrote:

I tried it and the same error message is still there.

"Dave Peterson" wrote:

Drop the .worksheetfunction portion:

ufConsulta.cbo1.Value = Application.VLookup(numero, magneto, 13, false)



Omar wrote:

Hi,

Can anyone help me to find the error in this code?

Private Sub btn4_Click()
Dim magneto As Range
Dim numero
Dim valor
Set magneto = Worksheets("info").Range("A2:AW65536")
numero = ufConsulta.txt33.Value
ufConsulta.cbo1.Value = Application.WorksheetFunction.VLookup(numero,
magneto, 13, false)

Thanks in advance...

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
Why do I get VLookup error 1004 KenG Excel Discussion (Misc queries) 2 March 28th 10 01:24 PM
Ghost in the Machine - 1004 Vlookup & On Error Duo Trouble VBANovice Excel Worksheet Functions 2 May 22nd 09 06:07 PM
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
VBA VLookup Problem: Run-Time error '1004' hurlbut777 Excel Programming 4 February 5th 05 12:43 AM


All times are GMT +1. The time now is 04:45 PM.

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

About Us

"It's about Microsoft Excel"