Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Why do I get VLookup error 1004 | Excel Discussion (Misc queries) | |||
Ghost in the Machine - 1004 Vlookup & On Error Duo Trouble | Excel Worksheet Functions | |||
Error 1004, Application-definded or object-defined error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
VBA VLookup Problem: Run-Time error '1004' | Excel Programming |