Buen día a todos Alguien me podría ayudar con esta macro, lo único que quiero es agregarle un mensaje, que cuando busca y no encuentra ningún registro; me diga que no lo encontró Deje la macro.. desde ya muchas gracias
Private Sub CommandButton1_Click() ListBox1.Clear If IsDate(TextBox1) Then buscar = CDate(TextBox1) Else buscar = TextBox1 End If If buscar = "" Then Exit Sub With Worksheets("RUCs empresas").Range("D:D") Set esta = .Find(buscar, LookIn:=xlValues) If Not esta Is Nothing Then primeracelda = esta.Address Do ListBox1.ColumnCount = 3 ListBox1.AddItem "" ListBox1.List(ListBox1.ListCount - 1, 0) = esta.Address ListBox1.List(ListBox1.ListCount - 1, 1) = esta ListBox1.List(ListBox1.ListCount - 1, 2) = esta.Offset(, 1) ListBox1.ColumnWidths = "40;50;100" Set esta = .FindNext(esta) Loop While Not esta Is Nothing And esta.Address <> primeracelda End If End With End Sub Private Sub CommandButton4_Click() Unload Me End Sub
Sub blanquea() Dim i As Byte For i = 1 To 21 Controls("TextBox" & i).Value = "" Next End Sub
'Para limpiar el BUSCADOR Private Sub CommandButton5_Click()
Dim Ctrl As Control
For Each Ctrl In BUSCADOR.Controls
If TypeOf Ctrl Is MSForms.TextBox Then
Ctrl = Empty
End If
Next Ctrl
End Sub 'Para limpiar la Lista Private Sub CommandButton6_Click() ListBox1.Clear End Sub Private Sub ListBox1_Click() Range(ListBox1.Column(0)).Select End Sub
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
Buen día a todos
Alguien me podría ayudar con esta macro, lo único que quiero es agregarle un mensaje, que cuando busca y no encuentra ningún registro; me diga que no lo encontró
Deje la macro.. desde ya muchas gracias
Private Sub CommandButton1_Click()
ListBox1.Clear
If IsDate(TextBox1) Then
buscar = CDate(TextBox1)
Else
buscar = TextBox1
End If
If buscar = "" Then Exit Sub
With Worksheets("RUCs empresas").Range("D:D")
Set esta = .Find(buscar, LookIn:=xlValues)
If Not esta Is Nothing Then
primeracelda = esta.Address
Do
ListBox1.ColumnCount = 3
ListBox1.AddItem ""
ListBox1.List(ListBox1.ListCount - 1, 0) = esta.Address
ListBox1.List(ListBox1.ListCount - 1, 1) = esta
ListBox1.List(ListBox1.ListCount - 1, 2) = esta.Offset(, 1)
ListBox1.ColumnWidths = "40;50;100"
Set esta = .FindNext(esta)
Loop While Not esta Is Nothing And esta.Address <> primeracelda
End If
End With
End Sub
Private Sub CommandButton4_Click()
Unload Me
End Sub
Sub blanquea()
Dim i As Byte
For i = 1 To 21
Controls("TextBox" & i).Value = ""
Next
End Sub
'Para limpiar el BUSCADOR
Private Sub CommandButton5_Click()
Dim Ctrl As Control
For Each Ctrl In BUSCADOR.Controls
If TypeOf Ctrl Is MSForms.TextBox Then
Ctrl = Empty
End If
Next Ctrl
End Sub
'Para limpiar la Lista
Private Sub CommandButton6_Click()
ListBox1.Clear
End Sub
Private Sub ListBox1_Click()
Range(ListBox1.Column(0)).Select
End Sub