Help on VB Excel

J

Joao Vaz

Run-time error '1004' - Unable to get the VLookup property of the
WorksheetFunction class. That's the error that I get from VB.

I have a VB program with a VLookup function.

Dim Numero, valor
Dim extenso
Do While Numero >= 0
extenso = Application.VLookup(Numero,
Worksheets("Tabelas").Range("R2:S40"), 2)

NUM DESIGN
0 zero
1 um
2 dois
3 tres
4 quatro
5 cinco
This is the Range in the Worksheet Tabelas.
This code works fine until I merge it with the application.
I need some help

Thanks,
Joao
 
J

Jim Thomlinson

Give this a try. It will be faster than the lookup...

Dim Numero, valor
Dim extenso
Do While Numero >= 0
extenso = NumeroToText(Numero)



Public Function NumeroToText(ByVal Numero As Integer) As String
Select Case Numero
Case 0
NumeroToText = "zero"
Case 1
NumeroToText = "um"
Case 2
NumeroToText = "dois"
Case 3
NumeroToText = "tres"
Case 4
NumeroToText = "quatro"
Case 5
NumeroToText = "cinco"
Case Else
NumeroToText = "Error"
End Select

End Function
 
J

Joao Vaz

Thank you Jim.
I use the VLookup function because the table is 40 lines long.
And I still don't understand the error.
Any help?

Joao
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top