Save the files in a selected folder using filedialogfolderpicker

selvendran

New Member
Joined
Aug 17, 2015
Messages
13
Hi all

I need your valuable expertise in modifying/tweaking the below code a little bit to make it work wonder. From below, myCell is a range of values containing the name of the files to be saved got produced out of this macro.

Instead of providing the fixed path/folder to save produced files, I have tried to open a dialog box to choose the destination folder where the files need to be saved. But it keeps on popping again for each file(until last value in myCell range) to select destination folder to save and that won't make much sense as no of files might go beyond 50.

My requirement is to open a dialog box for first file and once selected it should automatically saves all the files to the selected folder without popping again and again.

For Each myCell In TheRange

If Trim(myCell) <> "" Then
Sheets("Cover").Cells(myCell.Row, 66).Copy
Range("M31").Select
Selection.PasteSpecial Paste:=xlPasteValues
Call ComboBox1_Change
Calculate

'*******************CREATING NEW XL WORKSHEET & COPYING DATA**************************
Dim fd As FileDialog
Dim TempPath As String
Dim myFolder As Variant

ExtraSlash = "\"
Set fd = Application.FileDialog(msoFileDialogFolderPicker)

With fd
.AllowMultiSelect = False

If .Show = -1 Then

For Each myFolder In .SelectedItems

TempPath = myFolder & ExtraSlash
ActiveWorkbook.SaveCopyAs Filename:=TempPath & myCell & ".xlsm"

Next myFolder

End If

End With
Set fd = Nothing

End If

Next myCell

Thanks in advance!!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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