I am new to macros and need some help.
I have created a table in excel for various entities. I use a data validation drop down list to choose the entity. The tables are the same for each entity all that changes is the information based on the entity that is chosen. I want to develop a macro to print to pdf tables for each entity and save them in a folder on my desktop. Currently I have to chose from the each entity from the data validation list and then run a macro to print to pdf.
Basically I would like the macro to do the following:
1. Choose an entity from the validation list (this will populate the tables with information).
2. Print the tables to a PDF file and save to a specific folder calling the file the entity name which is in a cell underneath data validation list.
3. Repeat steps 1, 2 and 3 for every entity in the data validation list.
This is the macro that i am currently using to print to pdf. However I have to select the entity from the validation list and then run the macro each time. I would like to be able to press the print command button and it will run through the entire validation list and print each entity report as a separate pdf.
Private Sub CommandButton1_Click()
pdfname = Range("G3").Text
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="\\bviapp01\data\accounts\Mgmt Accts\PDF Reports\Entity PL\" + pdfname + ".pdf" _
, IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
Please let me know if you need any more information in order to assist. I have uploaded a sample file.
Thanks in advance for your help!! Much appreciated.
Sub drop_down_iterate() For i = 2 To 36 Sheets("Entity P&L").Range("G2").Value = Sheets("Seg1 2").Cells(i, 2).Value 'call the print macro Call macro_to_print MsgBox i Next i End Sub
I am totally new to VBA. I don't know how to sub my macro. Also could you please explain what call macro to print means and how I can incorporate my existing prinint macro into this so that it works. Thanks again.