ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help on VB Excel (https://www.excelbanter.com/excel-programming/350129-help-vbulletin-excel.html)

Joao Vaz

Help on VB Excel
 
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









Jim Thomlinson[_5_]

Help on VB Excel
 
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

--
HTH...

Jim Thomlinson


"Joao Vaz" wrote:

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









Joao Vaz

Help on VB Excel
 
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

"Jim Thomlinson" wrote:

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

--
HTH...

Jim Thomlinson


"Joao Vaz" wrote:

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










All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com