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!!
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!!