Saving as PDF file from drop down menu

futoko

New Member
Joined
Nov 4, 2020
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hello all, I'm trying to create a macro in excel to cycle and print one pdf for each item chosen in the drop down menu in A7. The file name should be the Lot # in the current chose item in drop down menu, and saved in the directory where the workbook is located. Any idea how? Thank you.
1604534198611.png
 

Attachments

  • 1604534078648.png
    1604534078648.png
    11.7 KB · Views: 4
  • 1604534164848.png
    1604534164848.png
    11.7 KB · Views: 4

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,864
The images contain a ton of information which is confusing the ultimate goal.

I'm guessing here ... would one PDF be all data contained in row #8 ... then a second PDF would be all data contained in row 9 ... etc., etc. ?

Should each PDF also have the data in Row #1, Row #5, Row #6 and the headers in Row #7 ?

It would be really nice to have a specific example of what the PDF would look like.
 

futoko

New Member
Joined
Nov 4, 2020
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
The images contain a ton of information which is confusing the ultimate goal.

I'm guessing here ... would one PDF be all data contained in row #8 ... then a second PDF would be all data contained in row 9 ... etc., etc. ?

Should each PDF also have the data in Row #1, Row #5, Row #6 and the headers in Row #7 ?

It would be really nice to have a specific example of what the PDF would look like.
Sorry, the images on first post was added by accident. You are correct, so basically the pdfs should look like this.
View attachment 25555
View attachment 25556
 

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,864
.
VBA Code:
Option Explicit

Sub CpyRws()
Dim fName
Dim i As Integer

    Application.ScreenUpdating = False
    
            With Worksheets("Sheet1") '<--- sheet name data copied from
                
                         For i = Cells(Rows.Count, "A").End(xlUp).Row To 8 Step -1
                            
                             If Sheets("Sheet1").Range("A" & i).Value <> "" Then
                                 Sheets("Sheet1").Rows(i).Copy Sheets("Temp").Range("A8")
                        
                                With Sheets("Temp")
                                    fName = .Range("A8").Value
                                    .ExportAsFixedFormat 0, Environ("USERPROFILE") & "\Desktop\" & _
                                    fName & ".pdf", OpenAfterPublish:=False
                                End With
                                
                            End If
                            
                        Next i
            
            End With
    Application.CutCopyMode = False
    Application.ScreenUpdating = True

Sheet1.Activate
Sheet1.Range("A1").Select
  
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,452
Messages
5,601,740
Members
414,470
Latest member
glukemey

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
Top