Te anexo todo el código para el form buscar
Dim h1
'
Private Sub cmb_eliminar_Click()
If txt_buscar.Value = "" Then
MsgBox "Escribe un dato a buscar", vbInformation, "JJ VIDEOJUEGOS"
Exit Sub
End If
If ListBox1.ListIndex = -1 Then
MsgBox "Selecciona un artículo", vbInformation, "JJ VIDEOJUEGOS"
Exit Sub
End If
fila = ListBox1.List(ListBox1.ListIndex, 4)
If (MsgBox("¿Se eliminará el artículo seleccionado?", vbCritical + vbYesNo, " JJ VIDEOJUEGOS") = vbYes) Then
h1.Rows(fila).Delete
MsgBox "Artículo eliminado", vbInformation, "JJ VIDEOJUEGOS"
Else
Cancel = 1
End If
'Call cmb_buscar_Click
'
txt_buscar = ""
ListBox1.Clear
End Sub
Private Sub cmb_volver_Click()
Unload Me
frm_articulos.Show
End Sub
Private Sub cmb_buscar_Click()
'Por.Dante Amor
ListBox1.Clear
If txt_buscar.Value = "" Then
MsgBox "Escribe un dato a buscar", vbInformation, "JJ VIDEOJUEGOS"
Exit Sub
End If
'
Set r = h1.Columns("B")
Set b = r.Find(txt_buscar, LookAt:=xlPart)
If Not b Is Nothing Then
celda = b.Address
Do
'detalle
ListBox1. AddItem h1. Cells(b.Row, "A")
ListBox1. List(ListBox1.ListCount - 1, 1) = h1. Cells(b.Row, "B")
ListBox1. List(ListBox1.ListCount - 1, 2) = h1. Cells(b.Row, "C")
ListBox1. List(ListBox1.ListCount - 1, 3) = h1. Cells(b.Row, "D")
ListBox1. List(ListBox1.ListCount - 1, 4) = h1. Cells(b.Row, "E")
ListBox1.List(ListBox1.ListCount - 1, 5) = b.Row
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> celda
End If
End Sub
Private Sub cmb_modificar_Click()
If txt_buscar.Value = "" Then
MsgBox "Escribe un dato a buscar", vbInformation, "JJ VIDEOJUEGOS"
Exit Sub
End If
'Por.Dante Amor
If ListBox1.ListIndex = -1 Then
MsgBox "Selecciona un artículo", vbInformation, "JJ VIDEOJUEGOS"
Exit Sub
End If
Unload Me
With frm_articulos_modificar
.fila = ListBox1.List(ListBox1.ListIndex, 4)
.Show
End With
'
txt_buscar = ""
ListBox1.Clear
End Sub
Private Sub ListBox1_Click()
'Por.Dante Amor
ruta = ThisWorkbook.Path & "\Imagenes\"
arch = ListBox1.List(ListBox1.ListIndex, 0) & ".jpg"
If Dir(ruta & arch) <> "" Then
img_articulos.Picture = LoadPicture(ruta & arch)
img_articulos.PictureSizeMode = fmPictureSizeModeStretch
Else
If Dir(ruta & "ART14350000.jpg") <> "" Then
img_articulos.Picture = LoadPicture(ruta & "ART14350000.jpg")
img_articulos.PictureSizeMode = fmPictureSizeModeStretch
End If
End If
End Sub
Private Sub txt_buscar_Change()
If txt_buscar.Value = "" Then
ListBox1.Clear
cmb_modificar.Enabled = False
cmb_eliminar.Enabled = False
Else
cmb_modificar.Enabled = True
cmb_eliminar.Enabled = True
Exit Sub
End If
End Sub
'
Private Sub UserForm_activate()
Set h1 = Sheets("ARTICULOS")
Sheets(2).Select
Range("A2").Select
txt_buscar.SetFocus
cmb_modificar.Enabled = False
cmb_eliminar.Enabled = False
End Sub
.
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias
.
Avísame cualquier duda
.