Hola a todos...quisiera saber como hacer para que esta macro me busque palabras que se encuentran dentro de una cadena de texto.
Ej. Combustible - Estación de Servicios Internacional - RAMIREZ GALEANO MILCIADES VIDAL......es decir escriba "Estación o Servicios o Vidal y que me lo encuentre
He probado de diferente manera y no pude dar con el...creo que mi problema está en esta linea....... palabra = VBA.Format(Me.TextBox2, "*")
Esta es la macro que dispongo
Private Sub CommandButton2_Click()
Dim palabra As String
With Range("E1:E" & Range("E" & Rows.Count).End(xlUp).Row)
palabra = VBA.Format(Me.TextBox2, "*")
Set fil = .Find(palabra, After:=ActiveCell, LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlNext)
If fil Is Nothing Then
MsgBox "No hay datos con este criterio: " & Me.TextBox2, vbExclamation, "Error!"
Me.TextBox2.SetFocus
Exit Sub
End If
fil.Activate
Me.Label2 = fil.Offset(0, -1) 'fil.Offset(0, 1) esto muestra lo mismo que Range("B" & fil.Row)
End With
Set fil = Nothing
End Sub
Private Sub CommandButton3_Click()
Me.Label2 = ""
Me.TextBox2.SetFocus
Range("E1").Select
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub UserForm_Initialize()
Me.Label2 = ""
Me.TextBox2.SetFocus
Range("E1").Select
End Sub
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
Hola a todos...quisiera saber como hacer para que esta macro me busque palabras que se encuentran dentro de una cadena de texto.
Ej. Combustible - Estación de Servicios Internacional - RAMIREZ GALEANO MILCIADES VIDAL......es decir escriba "Estación o Servicios o Vidal y que me lo encuentre
He probado de diferente manera y no pude dar con el...creo que mi problema está en esta linea....... palabra = VBA.Format(Me.TextBox2, "*")
Esta es la macro que dispongo
Private Sub CommandButton2_Click()
Dim palabra As String
With Range("E1:E" & Range("E" & Rows.Count).End(xlUp).Row)
palabra = VBA.Format(Me.TextBox2, "*")
Set fil = .Find(palabra, After:=ActiveCell, LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlNext)
If fil Is Nothing Then
MsgBox "No hay datos con este criterio: " & Me.TextBox2, vbExclamation, "Error!"
Me.TextBox2.SetFocus
Exit Sub
End If
fil.Activate
Me.Label2 = fil.Offset(0, -1) 'fil.Offset(0, 1) esto muestra lo mismo que Range("B" & fil.Row)
End With
Set fil = Nothing
End Sub
Private Sub CommandButton3_Click()
Me.Label2 = ""
Me.TextBox2.SetFocus
Range("E1").Select
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub UserForm_Initialize()
Me.Label2 = ""
Me.TextBox2.SetFocus
Range("E1").Select
End Sub