Dim sh As Worksheet, sht As Worksheet
Private Sub CommandButton1_Click()
If LB_00.ListIndex = -1 Then
MsgBox "Select item"
Exit Sub
End If
If LB_00.Selected(LB_00.ListIndex) = False Then
MsgBox "Select item"
Exit Sub
End If
'
'borrar registro
Dim fila As Long
'recupera el número de fila almacenado en el listbox
fila = Val(LB_00.List(LB_00.ListIndex, 12))
sh.Rows(fila).Delete
Call Load_ListBox
LB_00.Height = "177.95"
End Sub
Private Sub LB_00_Click()
LB_00.Height = "177.95"
End Sub
Private Sub T_00_Change()
LB_00.RowSource = ""
If T_00 = "" Then Exit Sub
If C_00.ListIndex = -1 Then
MsgBox "Selecciona una columna"
Exit Sub
End If
Call Load_ListBox
LB_00.Height = "177.95"
End Sub
Private Sub UserForm_activate()
Dim r As Range, j As Long
Set sh = Sheets("EVENTOS")
Set sht = Sheets("Temp")
C_00.List = Split("FECHA LUGAR HAB NOMBRE ESTADO VENDEDOR")
With LB_00
.ColumnCount = 13
.ColumnHeads = True
.ColumnWidths = ("100;100;100;0;80;50;250;100;0;100;100;200;0")
End With
Call Load_ListBox
End Sub
Sub Load_ListBox()
Application.ScreenUpdating = False
Dim i As Long, j As Long, f As Range, col As Long, existe As Boolean
i = 2
j = 2
sht.Cells.Clear
sh.Rows(1).Copy
sht.Range("A1").PasteSpecial xlPasteValues
Do While sh.Range("A" & i) <> ""
existe = False
If T_00 = "" Then
existe = True
Else
'aplicar filtros
Set f = sh.Rows(1).Find(C_00, , xlValues, xlWhole)
If Not f Is Nothing Then
col = f.Column
If LCase(sh.Cells(i, col)) Like "*" & LCase(T_00) & "*" Then
existe = True
End If
End If
End If
If existe Then
sh.Rows(i).Copy
sht.Range("A" & j).PasteSpecial xlPasteValues
sht.Range("A" & j).PasteSpecial xlPasteFormats
sht.Range("M" & j).Value = i 'almacena el número de fila
j = j + 1
End If
i = i + 1
Loop
LB_00.RowSource = sht.Name & "!A2:M" & j - 1
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Private Sub Cmd_00_Click()
Unload Me
'ActiveWorkbook.Close SaveChanges:=True
End Sub