problema con funcion VLOOKUP
Publicado por Fernando (1 intervención) el 10/03/2011 03:11:17
Hola gente tengo un problema que no puedo solucionar y me tiene loco. Es para un proyecto que tengo en el laburo. EL PROBLEMA ES EL SIGUIENTE: tengo que hacer un programita sencillo que me busque un dato en una celda y me devuelva el correspondiente en la siguiente fila .. o sea la funcion =buscarv de exel.. pero la tengo que llamar desde visual basic.. el tema es que no me devuelve ningun valor y nose que puedo estar haciendo mal... les dejo el codigo y muchas gracias de antemano.
Private Sub Command2_Click()
Dim EXL As Excel.Application
Dim W As Excel.Workbook
Dim S As Excel.Worksheet
Set EXL = New Excel.Application
Set W = EXL.Workbooks.Open("D:\acuarela.xls")
Set S = W.Sheets("Hoja1")
Dim IdClie As String
IdClie = Text1.Text
Dim Result As String
Result = Text2.Text
On Error Resume Next
Result = W.WorksheetFunction.VLookup(IdClie, S.Range("A1:C4"), 2, 0)
Set S = Nothing
W.Close
Set W = Nothing
Set EXL = Nothing
End Sub
Private Sub Command2_Click()
Dim EXL As Excel.Application
Dim W As Excel.Workbook
Dim S As Excel.Worksheet
Set EXL = New Excel.Application
Set W = EXL.Workbooks.Open("D:\acuarela.xls")
Set S = W.Sheets("Hoja1")
Dim IdClie As String
IdClie = Text1.Text
Dim Result As String
Result = Text2.Text
On Error Resume Next
Result = W.WorksheetFunction.VLookup(IdClie, S.Range("A1:C4"), 2, 0)
Set S = Nothing
W.Close
Set W = Nothing
Set EXL = Nothing
End Sub
Valora esta pregunta


0