• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

Looping macro to create PDFs|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Looping macro to create PDFs|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosLooping macro to create PDFs
sp_PrintTopic sp_TopicIcon
Looping macro to create PDFs
Avatar
Netty Forster
Member
Members
Level 0
Forum Posts: 10
Member Since:
October 23, 2019
sp_UserOfflineSmall Offline
1
June 5, 2020 - 4:53 pm
sp_Permalink sp_Print sp_EditHistory

I have been passed a workbook that is used to process bids for supplying transport for schools. It calculates the winning bid, then generates a letter to the successful bidder, and then letters to the unsuccessful bidders, all of which are then saved as a PDF saved to a specific file path. The macros that generate the PDFs aren't the best - the workbook is currently set up to deal with a maximum of 20 bids, and there are 20 macros to then generate the PDFs. I'm sure there should be a simpler way to do this by having one or two macros that run on a loop based on the number of bidders. The team have said that there may be an occasion when there are more than 20 bids so I think this definitely needs to be on some loop. Unfortunately my VBA knowledge is a little limited, I can read and understand macros but I'm not confident creating more complex ones by scratch so I'm hoping that one of you amazing people could help. I've attached the workbook which I've anonymised as much as I can.

I should say that the workbook is password protected and the password is: Evaluation

Thank you

sp_AnswersTopicSeeAnswer See Answer
Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 414
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
2
June 6, 2020 - 6:05 pm
sp_Permalink sp_Print sp_EditHistory

Its not perfect or the most efficent as i have tried to keep your formating and i dont want to break anything else, but i have made a loop on the unsuccessful bidders.

I also dont know if there are any other parts of the Macro that limit the number of letters, but i have tested with 7

The pdf's are currently being saved to SavePath = "C:\MOTH\" so you will need to uncomment the savepath line in the AllPDFS Module

Just click the Create PDFs button

Purfleet

sp_AnswersTopicAnswer
Answers Post
Avatar
Netty Forster
Member
Members
Level 0
Forum Posts: 10
Member Since:
October 23, 2019
sp_UserOfflineSmall Offline
3
June 8, 2020 - 3:14 pm
sp_Permalink sp_Print

Hi Purfleet

This is amazing. Thank you so much.

I've adjusted the file path and it is working brilliantly. One fly in the ointment though. The macro seems to create one less unsuccessful letter than there are unsuccessful bidders. So if there were 7 bidders it generates 1 award report, 1 successful letter and 5 unsuccessful letters when there should be 6.

Sorry to be a pain but I can't see what I should adjust in the macro to get the final unsuccessful letter to save as a PDF.

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 414
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
4
June 8, 2020 - 6:10 pm
sp_Permalink sp_Print

hmmm, it created 6 for me - do you know what one is missing?

Looping-macro-to-create-PDFs_purfleet.pngImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage Looping-macro-to-create-PDFs_purfleet.png (11 KB)
Avatar
Netty Forster
Member
Members
Level 0
Forum Posts: 10
Member Since:
October 23, 2019
sp_UserOfflineSmall Offline
5
June 11, 2020 - 3:52 pm
sp_Permalink sp_Print sp_EditHistory

That's really strange, I've just tried it again and it's worked perfectly! Thank you so much for your help 🙂

Avatar
Netty Forster
Member
Members
Level 0
Forum Posts: 10
Member Since:
October 23, 2019
sp_UserOfflineSmall Offline
6
June 11, 2020 - 5:28 pm
sp_Permalink sp_Print

I've just tried adding in the address information for each of the bidders and now it wont create the pdfs for the unsuccessful bidders.

In the Create All PDFs macro it's debugging at

Worksheets("Unsuccessful Letter Temp").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
SavePath & "UnsuccessfulLetter " & Bidder & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

It creates the Award Report and the Successful Bidder PDFs perfectly

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Fluff, Ineke Smit
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 186
Newest Members:
Kate Dyka
Kwaje Alfred Mogga
thong nguyen
Appiagyei Kofi Frimpong
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
Siobhan Stringer
Forum Stats:
Groups: 3
Forums: 24
Topics: 6546
Posts: 28658

 

Member Stats:
Guest Posters: 49
Members: 32832
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate
  • Sponsor Our Newsletter

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.