How to save a excel data range in dynamic folder path

Designernadir

New Member
Joined
Aug 4, 2019
Messages
8
Can anyone please guide me with a VBA to save my pdf file into different folders everytime I save it. I want the VBA to pick up the destination folder name from a cell reference.
Currently I am using the below VBA to same my pdf to two different drives in our network. But I want the E drive folder destination to be dynamic. is it possible? plzz


Option Explicit
Sub SaveQuotationinPDF()

Sheet1.Range("MOY125:MPD183").ExportAsFixedFormat xlTypePDF, Filename:="Z:\QUOTATIONS\QUOTATIONS (ARMO)\2020 -With sales code\Nadir\" & Sheet1.Range("MPC132").Value, openafterpublish:=True

Sheet1.Range("MOY125:MPD183").ExportAsFixedFormat xlTypePDF, Filename:="E:\My Documents\Armoplast\Armoplast Customer DIR\Local Quotations 13 Aug 2020\" & Sheet1.Range("MPC132").Value, openafterpublish:=True


End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try this:
VBA Code:
Sub SaveQuotationinPDF()
  With Sheet1.Range("MOY125:MPD183")
    .ExportAsFixedFormat xlTypePDF, Filename:="Z:\QUOTATIONS\QUOTATIONS (ARMO)\2020 -With sales code\Nadir\" & Sheet1.Range("MPC132").Value, openafterpublish:=True
    .ExportAsFixedFormat xlTypePDF, Filename:=Sheet1.Range("A1").Value & Sheet1.Range("MPC132").Value, openafterpublish:=True
  End With
End Sub
 
Upvote 0
Hi,
Let me rephrase my query...........
I have a master folder called "quotations"
Inside "Quotations" folder, I have sub folder ........
Customer 1
Customer 2
Customer 3
Customer 4 Etc

So , when I am creating a quotation in the excel quotation file for "Customer 2", while saving the file I want the file to be saved automatically in "Customer 2" sub folder.
Similarly, next time when I will create quotation for customer 4 or other, the file should automatically be saved in that particular sub folder.

Regards
designernadir
 
Upvote 0
I'm going to make another attempt, because I really don't know where you want to save and what data to put and where to put it.
Change the "main" folder in sPath and change "A1" to the cell where you have the name of the "customer folder".

VBA Code:
Sub SaveQuotationinPDF()
dim sPath as string
sPath =  "E:\My Documents\Armoplast\Armoplast Customer DIR\Local Quotations 13 Aug 2020\"
  With Sheet1.Range("MOY125:MPD183")
    .ExportAsFixedFormat xlTypePDF, Filename:="Z:\QUOTATIONS\QUOTATIONS (ARMO)\2020 -With sales code\Nadir\" & Sheet1.Range("MPC132").Value, openafterpublish:=True
    .ExportAsFixedFormat xlTypePDF, Filename:=sPath & Sheet1.Range("A1").Value & "\" & Sheet1.Range("MPC132").Value, openafterpublish:=True
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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