Hola Ojala alguien ojala pueda ayudarme y de antemano agradezco la ayuda para detectar donde esta el error en mi Macro
estoy creando una base de datos y en un Form trae la información a un ListBox , hasta acá todo bien pero quiero que al dar Clic en alguna linea de la información del listbox me traiga un valor a aun texbox y esto es lo que no logro
estoy usando WorksheetFunction.VLookup pero por más que veo no hace nada al hacer clic en el listBox
Private Sub ListBox1_Click()
On Error GoTo ErrorHandler
cuenta = FormNuevoProducto.ListBox1.ListCount
For i = 0 To cuenta - 1
If FormNuevoProducto.ListBox1.Selected(i) = True Then
cuenta = FormNuevoProducto.ListBox1.List(i)
End If
Next i
FormNuevoProducto.TextBox1 = Application.WorksheetFunction.VLookup(cuenta, Sheets("CATALOGOMP").Range("CatalogoMP"), 5, 0)
Dim nEditarRegistro As Integer
ErrorHandler:
If Err.Number = 1004 Then
With Me
End With
End If
End Sub
Function nEditarRegistro(nombre As String) As Integer
Application.ScreenUpdating = False
Sheets("CATALOGOMP").Activate
Range("A2").Activate
nEditarRegistro = 0
Do While Not IsEmpty(ActiveCell)
If nombre = ActiveCell Then
nEditarRegistro = ActiveCell.Row
End If
ActiveCell.Offset(0, 0).Select
Loop
Application.ScreenUpdating = True
End Function
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
Hola Ojala alguien ojala pueda ayudarme y de antemano agradezco la ayuda para detectar donde esta el error en mi Macro
estoy creando una base de datos y en un Form trae la información a un ListBox , hasta acá todo bien pero quiero que al dar Clic en alguna linea de la información del listbox me traiga un valor a aun texbox y esto es lo que no logro
estoy usando WorksheetFunction.VLookup pero por más que veo no hace nada al hacer clic en el listBox
Private Sub ListBox1_Click()
On Error GoTo ErrorHandler
cuenta = FormNuevoProducto.ListBox1.ListCount
For i = 0 To cuenta - 1
If FormNuevoProducto.ListBox1.Selected(i) = True Then
cuenta = FormNuevoProducto.ListBox1.List(i)
End If
Next i
FormNuevoProducto.TextBox1 = Application.WorksheetFunction.VLookup(cuenta, Sheets("CATALOGOMP").Range("CatalogoMP"), 5, 0)
Dim nEditarRegistro As Integer
ErrorHandler:
If Err.Number = 1004 Then
With Me
End With
End If
End Sub
Function nEditarRegistro(nombre As String) As Integer
Application.ScreenUpdating = False
Sheets("CATALOGOMP").Activate
Range("A2").Activate
nEditarRegistro = 0
Do While Not IsEmpty(ActiveCell)
If nombre = ActiveCell Then
nEditarRegistro = ActiveCell.Row
End If
ActiveCell.Offset(0, 0).Select
Loop
Application.ScreenUpdating = True
End Function