Te anexo el código para el userform1 para exportar a pdf
Private Sub CommandButton1_Click()
'Por.Dante Amor
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
ListBox1.Clear
If ComboBox1.Value = "" Then
MsgBox "Captura una fecha desde"
Exit Sub
End If
fec1 = CDate(ComboBox1.Value)
If ComboBox2 = "" Then
fec2 = fec1
Else
fec2 = CDate(ComboBox2.Value)
End If
'
For i = 3 To Range("E" & Rows.Count).End(xlUp).Row
If Cells(i, "E").Value >= fec1 And Cells(i, "E") <= fec2 Then
ListBox1.AddItem Cells(i, "A")
ListBox1. List(ListBox1.ListCount - 1, 1) = Cells(i, "B")
ListBox1. List(ListBox1.ListCount - 1, 2) = Cells(i, "C")
ListBox1. List(ListBox1.ListCount - 1, 3) = Cells(i, "D")
ListBox1. List(ListBox1.ListCount - 1, 4) = Cells(i, "E")
ListBox1. List(ListBox1.ListCount - 1, 5) = Format(Cells(i, "F"), "hh:mm")
ListBox1. List(ListBox1.ListCount - 1, 6) = Format(Cells(i, "G"), "hh:mm")
ListBox1. List(ListBox1.ListCount - 1, 7) = Cells(i, "H")
End If
Next
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub CommandButton2_Click()
'exportar
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
u = Range("F" & Rows.Count).End(xlUp).Row
f1 = Format(ComboBox1.Value, "mm/dd/yyyy")
If ComboBox2.Value = "" Then
f2 = f1
Else
f2 = Format(ComboBox2.Value, "mm/dd/yyyy")
End If
ActiveSheet.Range("$A$2:$H$" & u).AutoFilter Field:=5, Criteria1:= _
">=" & f1, Operator:=xlAnd, Criteria2:="<=" & f2
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ThisWorkbook.Path & "\Ingresar.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
End Sub
'
Private Sub UserForm_Activate()
For i = 3 To Range("E" & Rows.Count).End(xlUp).Row
Call Agregar(ComboBox1, Cells(i, "E").Value)
Call Agregar(ComboBox2, Cells(i, "E").Value)
Next
End Sub
'
Sub Agregar(combo As ComboBox, dato As String)
'por.DAM agrega los item únicos y en orden alfabético
For i = 0 To combo.ListCount - 1
Select Case StrComp(combo.List(i), dato, vbTextCompare)
Case 0: Exit Sub 'ya existe en el combo y ya no lo agrega
Case 1: combo.AddItem dato, i: Exit Sub 'Es menor, lo agrega antes del comparado
End Select
Next
combo.AddItem dato 'Es mayor lo agrega al final
End Sub
sal u dos