good morning,
Newbie here...i have a macro for auto generating tabs into PDFs and save them. the issue i'm having is that it is randomly skipping over some of the tabs. anyone have an idea how to fix this?
I checked the ones that get skipped to see if cell "A5" is the problem but it is not, as it has the exact same cell value but chooses to generate randomly (although its consistently the same tabs, and never different ones)...i have no idea how else to audit this.
please help, and thank you in advance!
Newbie here...i have a macro for auto generating tabs into PDFs and save them. the issue i'm having is that it is randomly skipping over some of the tabs. anyone have an idea how to fix this?
I checked the ones that get skipped to see if cell "A5" is the problem but it is not, as it has the exact same cell value but chooses to generate randomly (although its consistently the same tabs, and never different ones)...i have no idea how else to audit this.
please help, and thank you in advance!
Code:
[TABLE="width: 493"]
<colgroup><col></colgroup><tbody>[TR]
[TD]Option Explicit[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'-------------------------------------------------------------------------------[/TD]
[/TR]
[TR]
[TD]Sub Save_as_Pdfs()[/TD]
[/TR]
[TR]
[TD]'-------------------------------------------------------------------------------[/TD]
[/TR]
[TR]
[TD]' Saves marked sheets as PDF file.[/TD]
[/TR]
[TR]
[TD]Dim PDF_path As String[/TD]
[/TR]
[TR]
[TD]Dim Snr As Integer[/TD]
[/TR]
[TR]
[TD]Dim Name As String[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]PDF_path = "d:\PDF\" 'edit path as required[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]On Error Resume Next[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'Process all sheets in workbook[/TD]
[/TR]
[TR]
[TD]For Snr = 1 To ActiveWorkbook.Sheets.Count[/TD]
[/TR]
[TR]
[TD] Sheets(Snr).Activate[/TD]
[/TR]
[TR]
[TD] 'Only print if A5 contains "YES"[/TD]
[/TR]
[TR]
[TD] If Cells(5, "A").Value = "YES" Then[/TD]
[/TR]
[TR]
[TD] Name = PDF_path & ActiveSheet.Name & Cells(4, "B").Value & ".pdf"[/TD]
[/TR]
[TR]
[TD] ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Name, _[/TD]
[/TR]
[TR]
[TD] Quality:=xlQualityStandard, IncludeDocProperties:=False, _[/TD]
[/TR]
[TR]
[TD] IgnorePrintAreas:=False, OpenAfterPublish:=False[/TD]
[/TR]
[TR]
[TD] End If[/TD]
[/TR]
[TR]
[TD]Next Snr[/TD]
[/TR]
[TR]
[TD]End Sub[/TD]
[/TR]
</tbody>[/TABLE]