macro is skipping tabs

jadams121

New Member
Joined
Jul 18, 2019
Messages
12
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!

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]
 
gotcha...darn NEWBIES!!...I will fix the backslashes and see where that gets me....thanks so much for your help, Fluff
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top