Anexo el código
Dim h, h3
'
Private Sub ComboBox1_Change()
End Sub
'
Private Sub ComboBox2_Change()
'Por.Dante Amor
Label10.Caption = ""
If ComboBox2 = "" Or ComboBox2.ListIndex = -1 Then
Exit Sub
End If
f = ComboBox2.ListIndex + 2
Label10.Caption = h.Cells(f, "B")
End Sub
'
Private Sub CommandButton1_Click()
'
' Por Dante Amor
'
If ComboBox1.Value = "" Or ComboBox1.ListIndex = -1 Then
MsgBox "Selecciona un Empresa", vbExclamation, "INGRESAR"
ComboBox1.SetFocus
Exit Sub
End If
If TextBox1.Value <> "" Then
If Not IsDate(TextBox1.Value) Then
MsgBox "Captura una fecha valida", vbExclamation, "INGRESAR"
TextBox1.SetFocus
Exit Sub
End If
End If
' If ComboBox2.Value = "" Or ComboBox2.ListIndex = -1 Then
' MsgBox "Selecciona un Código", vbExclamation, "INGRESAR"
' ComboBox2.SetFocus
' Exit Sub
' End If
' If TextBox4.Value = "" Or Not IsNumeric(TextBox4.Value) Then
' MsgBox "Captura una Cantidad valida", vbExclamation, "INGRESAR"
' TextBox4.SetFocus
' Exit Sub
' End If
'
Set h1 = Sheets(ComboBox1.Value)
h3.Range("AB1:AE3").ClearContents
h3.Range("AB1") = h1.Range("A2") 'fecha
h3.Range("AC1") = h1.Range("A2") 'fecha
h3.Range("AD1") = h1.Range(" B2") 'cod
'h3.Range("E1") = h1.Range("C2")
'
If ComboBox2.ListIndex > -1 Then
If IsNumeric(ComboBox2.Value) Then codigo = Val(ComboBox2.Value) Else codigo = ComboBox2.Value
h3.Range("AD2").Value = codigo
End If
If TextBox1.Value <> "" Then
h3.Range("AB3") = CDate(TextBox1)
h3.Range("AB2") = "="">=""&R[1]C"
If TextBox2.Value = "" Then
h3.Range("AC3") = CDate(TextBox1)
h3.Range("AC2") = "=""<=""&R[1]C"
End If
End If
If TextBox2.Value <> "" Then
If IsDate(TextBox2) Then
If CDate(TextBox2) >= CDate(TextBox1) Then
h3.Range("AC3") = CDate(TextBox2)
h3.Range("AC2") = "=""<=""&R[1]C"
Else
MsgBox "Captura una fecha hasta valida"
TextBox2.SetFocus
Exit Sub
End If
Else
MsgBox "Captura una fecha hasta valida"
TextBox2.SetFocus
Exit Sub
End If
End If
'
Application.ScreenUpdating = False
u = h1.Range("A" & Rows.Count).End(xlUp).Row + 1
h1.Range("A2:H" & u).AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=h3.Range("AB1:AE2"), CopyToRange:=h3.Range("B1:I1"), Unique:=False
h3.Columns("B:I").WrapText = False
h3.Columns("B:I").EntireColumn.AutoFit
Application.ScreenUpdating = True
End Sub
'
Sub Limpiar()
ComboBox1.Value = ""
ComboBox2.Value = ""
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
End Sub
'
Private Sub UserForm_Activate()
Set h = Sheets("Listado")
Set h3 = ActiveSheet
'carga códigos
For i = 2 To h.Range("A" & Rows.Count).End(xlUp).Row
ComboBox2.AddItem h.Cells(i, "A")
Next
'carga empresas
For i = 2 To h.Range("D" & Rows.Count).End(xlUp).Row
ComboBox1.AddItem h.Cells(i, "D")
Next
End Sub
'
Private Sub CommandButton2_Click()
Unload Me
End Sub
Sal u dos