Hi there,
I have a VBA code to split sheets, but now I want to save them as PDF.
And there for I have a code but do not know how to add to the code to the VBA code.
Can some help, I'm lost.....
Split code:
Private Sub CommandButton1_Click()
Dim Cl As Range
Dim ws As Worksheet
Dim Ky As Variant
Application.ScreenUpdating = False
Set ws = Sheets("OSAP Orders")
With CreateObject("scripting.dictionary")
For Each Cl In ws.Range("D2", ws.Range("D" & Rows.Count).End(xlUp).Offset(-1))
If Not .Exists(Cl.Value) And Cl.Value <> "" Then .Add Cl.Value, Nothing
Next Cl
For Each Ky In .Keys
ws.Range("A1").AutoFilter 4, Ky
Sheets.Add(, ws).Name = Ky
ws.AutoFilter.Range.EntireRow.Copy Sheets(Ky).Range("A1")
Sheets(Ky).Columns.AutoFit
Next Ky
End With
ws.AutoFilterMode = True
ws.Activate
End Sub
safe to PDF code:
'save splitted files to PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Documents" & Format(Now(), "yyyy-mm-dd") & " " & Cell.Value & ".pdf", _
OpenAfterPublish:=False
Greetings,
Steel010
I have a VBA code to split sheets, but now I want to save them as PDF.
And there for I have a code but do not know how to add to the code to the VBA code.
Can some help, I'm lost.....
Split code:
Private Sub CommandButton1_Click()
Dim Cl As Range
Dim ws As Worksheet
Dim Ky As Variant
Application.ScreenUpdating = False
Set ws = Sheets("OSAP Orders")
With CreateObject("scripting.dictionary")
For Each Cl In ws.Range("D2", ws.Range("D" & Rows.Count).End(xlUp).Offset(-1))
If Not .Exists(Cl.Value) And Cl.Value <> "" Then .Add Cl.Value, Nothing
Next Cl
For Each Ky In .Keys
ws.Range("A1").AutoFilter 4, Ky
Sheets.Add(, ws).Name = Ky
ws.AutoFilter.Range.EntireRow.Copy Sheets(Ky).Range("A1")
Sheets(Ky).Columns.AutoFit
Next Ky
End With
ws.AutoFilterMode = True
ws.Activate
End Sub
safe to PDF code:
'save splitted files to PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Documents" & Format(Now(), "yyyy-mm-dd") & " " & Cell.Value & ".pdf", _
OpenAfterPublish:=False
Greetings,
Steel010