Excel VBA Macro: Save Selected Range as PDF (and Center on Page)

  Рет қаралды 7,190

greggowaffles

greggowaffles

Күн бұрын

Excel VBA Macro: Save Selected Range as PDF (and Center on Page). In this video, we go over how to write code that allows us to select a range on a worksheet and only use that selected range to create a pdf, save the pdf, and align the range in the center of the page. We also go over how to include icons from excel in our new pdf.
Code:
Sub save_range_as_pdf()
Dim pdf_range As Range
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
Set pdf_range = ws.Range("B2:C14")
ws.PageSetup.CenterHorizontally = True
pdf_range.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Users\greggowaffles\Documents\" & _
"KZbin Videos\Test\Cookie Sales Reports\" & _
"Cookie Sales Report " & _
ws.Range("B11").Text & ".pdf", OpenAfterPublish:=True
End Sub
#ExcelVBA #ExcelMacro

Пікірлер: 11
@drewgossage8842
@drewgossage8842 2 жыл бұрын
Another great update!! Your style is just like someone casually showing you how to do something at work. Casual, yet really informative 👍👍
@greggowaffles
@greggowaffles 2 жыл бұрын
That’s the goal! I really appreciate the feedback!! Thank you 🙏
@Master-bx4rd
@Master-bx4rd 11 ай бұрын
Hi, Presented excercise looks very good. But I wanted to export a range e.g. A1:R50 into 1 pdf page only. I'm trying to do it, but it still expotrs to the 2 pages which is what I don't want to. Any help apreciated Regards
@selvan1264
@selvan1264 Жыл бұрын
Excellent video!!! May I check how to use excel VBA to save as secured pdf? The pdf will not be editable, cannot copy paste only for read only etc...Thank you
@MuntasirSaqif
@MuntasirSaqif Жыл бұрын
Thanks Greg , learned a lot by watching your videos. Quick question: I have a table of data and when saving the data to PDF, the PDF is displaying my table in multiple pages. For example, the category in one page and the corresponding sales in another. How can I fix this? Thanks
@MrHatem55
@MrHatem55 2 жыл бұрын
Hi thank you. Your videos helped me a lot at work Could you please do a video about how to get all updated documents from files? I have a file called “weekly report “ I want to gather only the updated documents 3 excel file and 1 word from different files to my main folder “Weekly report” is that doable? Thanks in advance 🙏🏽
@greggowaffles
@greggowaffles 2 жыл бұрын
Glad to hear that! I think so. So you want a macro that looks through certain folders and grabs the most updated documents in each folder to put in another folder?
@MrHatem55
@MrHatem55 2 жыл бұрын
@@greggowaffles Yes exactly. Plus it would be great if I can do the file can update it self weekly without me doing anything
@greggowaffles
@greggowaffles 2 жыл бұрын
ok cool. I’ll make a video on that and I’ll probably spread it across two videos to incorporate the second part
@MrHatem55
@MrHatem55 2 жыл бұрын
@@greggowaffles Thank you 🙏 ♥️ Waiting for your magic 🪄
@greggowaffles
@greggowaffles 2 жыл бұрын
🪄Excel VBA Macro: Open Newest Files (from Multiple Folders) and Save Them in Another Folder kzbin.info/www/bejne/l2qmi6xordpqb68
Export PDF from Excel on a Button Click
9:14
SVJ Academy
Рет қаралды 6 М.
Looks realistic #tiktok
00:22
Анастасия Тарасова
Рет қаралды 106 МЛН
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 46 МЛН
The Ultimate Guide to Copying Data using Excel VBA
31:05
Excel Macro Mastery
Рет қаралды 64 М.
Save Excel Sheet as PDF with Simple Macro - ExcelVbaIsFun
7:12
ExcelVbaIsFun
Рет қаралды 214 М.
5 Killer Excel VBA Tips Everyone Should Know
12:55
Excel Macro Mastery
Рет қаралды 109 М.
Excel VBA Save Range to PDF
11:26
The Excel Cave
Рет қаралды 20 М.
Excel VBA Macro: Save Active Sheet As PDF (Based on Cell Value)
7:14
10 awesome Power Query tricks you NEED to know! | Excel Off The Grid
15:44
Excel Off The Grid
Рет қаралды 34 М.
Excel VBA Macro: Save File As (Based on Cell Value)
5:44
greggowaffles
Рет қаралды 35 М.