Export each Sheet to PDF file in Excel by Using VBA Macros

bardimin pic

Bardimin

December 30, 2021
excel export pdf 02

Export each Sheet to PDF file in Excel by Using VBA Macros

Home » Blogs » Software » Export each Sheet to PDF file in Excel by Using VBA Macros

Have you ever created a PDF from a Sheet in ? Easy isn't it?

Creating PDF files from sheets in is an easy job. What if in the Excel file there are lots of sheets. For example, a report from sales in one month for each excel file consisting of 30 days, where each day's report is stored in a different sheet. Or maybe each excel file contains hundreds of sheets and you have to create a PDF file of each sheet.

excel export pdf 01

Pekerjaan yang mudah menjadi berat jika volumenya sangat besar. Tapi tidaEasy work becomes heavy if the volume is very large. But don't worry, using macros from Excel will not be a problem.

Export Excel sheet to PDF with Macro VBA

  1. Open Excel Macros, see how to create macros.
  2. Copy the following
Sub ExportToPDFs()
' Bardimin
' Export Sheet to PDF
' Save Each Worksheet to a separate PDF file.
 
Dim ws As Worksheet
Dim myFile As String
myFile = Application.ActiveWorkbook.Path

For Each ws In Worksheets
ws.Select
sheetName = ws.Name
 
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=myFile & "" & sheetName & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
 
Next ws
End Sub
  1. Run
excel export pdf 02

The export sheet to PDF will produce a PDF file with a name like a sheet name in Excel that you created and saved in the directory from the same as your excel file.

To change the name of the resulting PDF file, you can change the following line of code

Filename:=myFile & "" & sheetName & ".pdf", _

Good luck ……

link nyemin

Latest Articles

How to Create and Save Tab Groups in Google Chrome

How to Create and Save Tab Groups in Google Chrome

Google Chrome is one of the most popular web browsers in the world, with advanced features that make the surfing experience easier and more enjoyable. One feature recently introduced by Google is tab groups, which allow you to group and label the tabs you have opened...

What is a Memory Leak and How to Solve It?

What is a Memory Leak and How to Solve It?

Memory leak is one of the problems often faced by software developers, especially those who use programming languages such as C and C ++. Memory leaks occur when a program allocates memory from a heap but does not free it when it is no longer needed. As a result, the...

How to Create a Strong and Easy-to-Remember Password

How to Create a Strong and Easy-to-Remember Password

A password is the key to accessing your online accounts, be it email, social media, banking, or anything else. A strong and secure password will protect your account from hacker attacks, identity theft, or data misuse. However, strong passwords should also be easy to...

How to Find and Fix Packet Loss on Windows

How to Find and Fix Packet Loss on Windows

Packet loss is a serious problem that can negatively impact various applications and services. It is important to know how to test and fix Packet Loss to ensure that you have a stable and reliable connection. Packet loss is a term used to describe a situation when a...

LACP vs PAgP: What is the Difference and Relationship?

LACP vs PAgP: What is the Difference and Relationship?

LACP (Link Aggregation Control Protocol) and PAgP (Port Aggregation Protocol) are two protocols used to combine multiple physical ports into one logical port, referred to as link aggregation or channel port. The purpose of link aggregation is to increase bandwidth,...

TAG: