save each range contains month as pdf for specific sheet based on inputbox

Hasson

Active Member
Joined
Apr 8, 2021
Messages
388
Office Version
  1. 2016
Platform
  1. Windows
hello

I have files contain many sheets and each sheet contains data for 12 months .the data are a1:g and the column A contains date M/DD/YYYY . what I want macro to show inputbox and write the sheet after this should save all of the ranges for all the months separately not in one file . each month should be in one file for written sheet into inputbox as PDF , but when save for each month I would create the headers for each month which save as pdf . the headers in row1 , then when save for each month it should contain the headers .
the directory is D:\DATA , but when save in this directory should create folders and thier names based on sheets names and the files should save in sheet is relating of it
and if I run the macro repeatedly should pops up message " the files have already existed ,do you want replace them ? " if press ok then replace it , if press no then nothing happens .


thanks
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I have files contain many sheets and each sheet contains data for 12 months

Do you have several books?

If file1 has "monthly" sheet, what are the pdf files called for month 1, month 2...?
Now, if you have another file2, with a sheet with the same name "monthly", then what are the pdf files going to be called for month 1, month 2...?

The new folder will be named "D:\DATA\monthly\"?
 
Upvote 0
Do you have several books?
at least 12 files
If file1 has "monthly" sheet, what are the pdf files called for month 1, month 2...?
should be monthly
Now, if you have another file2, with a sheet with the same name "monthly", then what are the pdf files going to be called for month 1, month 2...?
yes , this is not problem because every file should create new folder as same file name inside directory
every new folder should create based on file name and save the sheets inside it . sorry if I don't make clear this point from the beginning .
 
Upvote 0
for correction
If file1 has "monthly" sheet, what are the pdf files called for month 1, month 2...?
yes you're right
 
Upvote 0
yes , this is not problem because every file should create new folder as same file name inside directory
every new folder should create based on file name and save the sheets inside it . sorry if I don't make clear this point from the beginning .
It's still unclear to me.
You can give examples of the names of your files, names of the sheets of each file.
Names of the destination folders, how the pdf files would look in each folder, and the name of each pdf.

Perform the example with at least 3 files.
 
Upvote 0
my apologies ! after see my OP you're right this is not clear and I don't mentioned so forget this
yes , this is not problem because every file should create new folder as same file name inside directory
every new folder should create based on file name and save the sheets inside it . sorry if I don't make clear this point from the beginning .
just create new folder based on sheet name and save each range based on month as pdf
 
Upvote 0
just create new folder based on sheet name and save each range based on month as pdf
It's not enough to understand what you want. You must give examples as I asked you in the previous post.
 
Upvote 0
sorry for delaying , it takes more time to do that .
file name PUR1 ,PUR2,SEARCH . take PUR1 should create folder based on folder name PUR1 to become the directory D:\DATA\PUR1\
the data in file PUR1 contains many sheets for instance take sheet name DTR then should crate folder name DTR inside folder PUR1 to become directory D:\DATA\PUR1\DTR\
the data in file PUR1
PUR1.xlsx
ABCDE
1DATEIDBARCODEWHARE HOUSE QTY
211/5/2021QQW-1 MM CLA1 23M-1 IT200.000
311/6/2021QQW-2 TH NM-1 CLA2 VBG L CHI300.000
411/7/2021QQW-3 CV CLA3 TA400.000
511/8/2021QQW-4 M*12.5 CLA4 TR500.000
611/9/2021QQW-5 CLA5 EG600.000
711/10/2021QQW-6 M230 TU700.000
811/11/2021QQW-7 S** CLA7 US800.000
911/12/2021QQW-8 CLA8 UK900.000
1011/13/2021QQW-9 CLA9 N BR1,000.000
1111/14/2021QQW-10 BN CLA10 IT1,100.000
1212/15/2021QQW-11 LVD CH1,200.000
1312/16/2021QQW-12 CLA12 JA1,300.000
1412/17/2021QQW-13 CLA13 TR1,400.000
1512/18/2021QQW-14 L/R CLA14 SS230 EG1,500.000
1612/19/2021QQW-15 CLA15 TU1,600.000
1712/20/2021QQW-16 CLA16 US1,700.000
1812/21/2021QQW-17 CLA17 UK1,800.000
1912/22/2021QQW-18 RRSDF BR1,900.000
2012/23/2021QQW-19 CLA19 IT2,000.000
2112/24/2021QQW-20 KV/1**2 CLA20 CHI2,100.000
DTR

so when create the folders & save files




f1.PNG


create folder DTR based on sheet name inside folder PUR1
f2.PNG

save each range based on month as pdf file
f3.PNG

to see inside files when open them
file MONTH_11
f4.PNG



MONTH_12


اf5.PNG



file name SEARCH
data
SEARCH.xlsm
ABCD
1ITEMIDDESCIBEPRODUCTION BY
22/11/2022QQW-1 MMCLA1 23M-1IT
32/12/2022QQW-2 TH NM-1CLA2 VBG LCHI
42/13/2022QQW-3 CVCLA3TAI
52/14/2022QQW-4 M*12.5CLA4TR
62/15/2022QQW-5CLA5EG
72/16/2022QQW-6M230TU
82/17/2022QQW-7 S**CLA7US
93/18/2022QQW-8CLA8UK
103/19/2022QQW-9CLA9 NBR
113/20/2022QQW-10 BNCLA10IT
123/21/2022QQW-11LVDCH
133/22/2022QQW-12CLA12JA
143/23/2022QQW-13CLA13TR
154/24/2022QQW-14 L/RCLA14 SS230EG
164/25/2022QQW-15CLA15TU
174/26/2022QQW-16CLA16US
184/27/2022QQW-17CLA17UK
194/28/2022QQW-18RRSDFBR
204/29/2022QQW-19CLA19IT
214/30/2022QQW-20 KV/1**2CLA20CHI
RP


create folder based on folder name SEARCH to become the directory D:\DATA\SEARCH\
the data in file SEARCH contains many sheets for instance take sheet name RP then should crate folder name RP inside folder SEARCH to become directory D:\DATA\SEARCH\RP\

so when create the folders & save files as pic1 will see creat folder search

create folder RP based on sheet name inside folder SEARCH
f5.PNG




save each range based on month as pdf file
f6.PNG


to see inside files when open them
MONTH2
f7.PNG



MONTH3
f8.PNG


MONTH4
f9.PNG

I hope this si help
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

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