How to export excel file to pdf

icytuvi

New Member
Joined
Feb 2, 2020
Messages
22
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I need to send the notice on new price list in .pdf format to various customers, and I really appreciate if you could help advise on how to do it at one go without having to export file for each and every customer.

I have the database in two sheets as below:

Sheet 1: the price list by region

Example.xlsx
ABCDE
2PRICE LIST BY REGION
3 Brand SKU Selangor Sarawak Mallaka
4 Samsung Galaxy Note 10 $ 800$ 820$ 830
5 Samsung Galaxy Note 10 Lite $ 700$ 720$ 730
6 Samsung Galaxy Ultra Note 20 $ 1,000$ 1,020$ 1,030
7 Apple Iphone 13 $ 1,200$ 1,220$ 1,230
8 Apple Iphone 12 Pro Max $ 1,100$ 1,120$ 1,130
9 Apple Iphone 12 $ 1,000$ 1,020$ 1,030
10 Apple Iphone 11 $ 800$ 820$ 830
11 Oppo Reno 5 $ 600$ 620$ 630
12 Xiaomi Redmi Note 5 $ 300$ 320$ 330
Price list
Cell Formulas
RangeFormula
D4:D12D4=C4+20
E4:E12E4=C4+30


Sheet 2: Customer list by region

Example.xlsx
ABCD
3#CodeCustomerRegion
41SE0001MarinaSelangor
52SA0001TracySarawak
63MA0001Wil C.Mallaka
74SE0002AreenSelangor
85SA0002ChrisSarawak
96MA0002MarkMallaka
107SE0003TaylorSelangor
118SA0003StephenSarawak
129MA0003ChloeMallaka
1310SE0004YokoSelangor
1411SA0004LeonoraSarawak
1512MA0004PhilMallaka
1613SE0005LanaSelangor
1714SA0005SamSarawak
1815MA0005TheodoraMallaka
Customer list


And I would like to export the notification to all customer based on this template:

Example.xlsx
ABCDEFGHI
3Dear Mr./Ms:Taylor7
4Location:Selangor
5
6Kindly be informed that from effective 18th Oct 2021, the follow price list will be applied at your region:
7
8 Brand SKU Price
9 Samsung Galaxy Note 10 $ 800
10 Samsung Galaxy Note 10 Lite $ 700
11 Samsung Galaxy Ultra Note 20 $ 1,000
12 Apple Iphone 13 $ 1,200
13 Apple Iphone 12 Pro Max $ 1,100
14 Apple Iphone 12 $ 1,000
15 Apple Iphone 11 $ 800
16 Oppo Reno 5 $ 600
17 Xiaomi Redmi Note 5 $ 300
18
19 Regards
Notice
Cell Formulas
RangeFormula
B3B3=VLOOKUP(C3,'Customer list'!$A$4:$C$18,3,0)
B4B4=VLOOKUP(B3,'Customer list'!$C$4:$D$18,2,0)
C9:C17C9=SUMPRODUCT(('Price list'!$C$3:$E$3=Notice!B$4)*('Price list'!$B$4:$B$12=Notice!B9)*('Price list'!$C$4:$E$12))


Thank you very much.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
This is similar to the function mail merge in MS Word, but I don't know how to do it in Excel. Any help would be greatly appreciated.
 
Upvote 0
Try this macro:
VBA Code:
Public Sub Create_PDFs()

    Dim r As Long
    Dim PDFfile As String
       
    With Worksheets("Customer list")
        For r = 4 To .Cells(.Rows.Count, "A").End(xlUp).Row
            PDFfile = ActiveWorkbook.Path & "\" & Join(Array(.Cells(r, "A").Value, .Cells(r, "B").Value, .Cells(r, "C").Value, .Cells(r, "D").Value)) & ".pdf"
            Worksheets("Notice").Range("C3").Value = .Cells(r, "A").Value
            Worksheets("Notice").ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFfile, Quality:=xlQualityStandard
        Next
    End With
    
    MsgBox "Done"
    
End Sub
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: How to export pdf from excel file
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: How to export pdf from excel file
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
Hi Moderator, thank you for reminding and I'm really sorry for this. Will not repeat next time
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: How to export pdf from excel file
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
Try this macro:
VBA Code:
Public Sub Create_PDFs()

    Dim r As Long
    Dim PDFfile As String
      
    With Worksheets("Customer list")
        For r = 4 To .Cells(.Rows.Count, "A").End(xlUp).Row
            PDFfile = ActiveWorkbook.Path & "\" & Join(Array(.Cells(r, "A").Value, .Cells(r, "B").Value, .Cells(r, "C").Value, .Cells(r, "D").Value)) & ".pdf"
            Worksheets("Notice").Range("C3").Value = .Cells(r, "A").Value
            Worksheets("Notice").ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFfile, Quality:=xlQualityStandard
        Next
    End With
   
    MsgBox "Done"
   
End Sub
Hi @John_w, thank you very much. Your code for exporting to multiple pdf files with file name set is brilliant!!! Could you please help incorporate the lookup function as well? Since in my excel file the data for each customer may be different from the others. I have been stuck with it for quite a long time but could not figure out how to do it :(

Appreciate if any one could help. Thanks a lot.
 
Upvote 0
Could you please help incorporate the lookup function as well? Since in my excel file the data for each customer may be different from the others.
You need to explain more. Which lookup function? Do you want the code to create the lookup formula (which one?), instead of you putting it in a cell in the "Notice" sheet? Which cell? Please describe what you want in more detail, and be specific.
 
Upvote 0
You need to explain more. Which lookup function? Do you want the code to create the lookup formula (which one?), instead of you putting it in a cell in the "Notice" sheet? Which cell? Please describe what you want in more detail, and be specific

Thank you for taking your time to help look at my matter. To understand more, could you please go and take a look at the excel file in the link below?


In short, let's say I have 100 customers in 20 regions, and to each region I may apply a price list different to other regions. I have the database containing all the customer name, region, and the corresponding price list. I want to send the price announcement to all of them in pdf format. The question is, how to do that without having to create each and every excel sheet for each customer, then export it manually to pdf. Your code above solve the matter of exporting to many pdf files at one go. It's will be perfect if the price totally match with the customer.
 
Upvote 0
Please do not ask members to look at other sites for data. Apart from anything else only members on that site will be able to access it.

If you want to share a file, you need to upload it to a share site, mark for sharing & then post the link you get to the thread.
Thanks
 
Upvote 0

Similar threads

Forum statistics

Threads
1,215,339
Messages
6,124,381
Members
449,155
Latest member
ravioli44

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