ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Modify Ron de Bruin Code; Save Specific Files to Specific Folders (https://www.excelbanter.com/excel-programming/443538-modify-ron-de-bruin-code%3B-save-specific-files-specific-folders.html)

ryguy7272[_2_]

Modify Ron de Bruin Code; Save Specific Files to Specific Folders
 
I’m trying to come up with a way of saving files that end in a
specific number to a specific folder. So, I’d use =right(A2,1) and if
the right most number is a 6, save to a folder named 6, if the right-
most number is 2, save to a folder named 2, if the right most number
is 5, save to a folder named 5, etc. My numbers would be in ColumnY.

The Ron de Bruin code below is super-slick:

http://www.rondebruin.nl/copy5_3.htm



How can I modify that code to copy unique values to a sheet, save the
sheet as the name of the value, and save each sheet to a SPECIFIC
folder?



Thanks for your time and consideration with this!!

ryguy7272[_2_]

Modify Ron de Bruin Code; Save Specific Files to Specific Folders
 
On Aug 24, 12:54*am, ryguy7272 wrote:
I’m trying to come up with a way of saving files that end in a
specific number to a specific folder. *So, I’d use =right(A2,1) and if
the right most number is a 6, save to a folder named 6, if the right-
most number is 2, save to a folder named 2, if the right most number
is 5, save to a folder named 5, etc. *My numbers would be in ColumnY.

The Ron de Bruin code below is super-slick:

http://www.rondebruin.nl/copy5_3.htm

How can I modify that code to copy unique values to a sheet, save the
sheet as the name of the value, and save each sheet to a SPECIFIC
folder?

Thanks for your time and consideration with this!!



Figured it out! Actually, I created the folders and just changed a
few lines of code:

ws1.AutoFilterMode = False
rng.AutoFilter Field:=FieldNum, Criteria1:="=" & cell.Value

ActiveSheet.Range("D3") = cell.Value


'Save the file and close it
If Mid(cell.Value, 9, 1) = 0 Then
foldername = "I:\Documents\ExcelTen\0\"
WSNew.Parent.SaveAs foldername & cell.Value & FileExtStr,
FileFormatNum
WSNew.Parent.Close True

ElseIf Mid(cell.Value, 9, 1) = 1 Then
foldername = "I:\Documents\ExcelTen\1\"
WSNew.Parent.SaveAs foldername & cell.Value & FileExtStr,
FileFormatNum
WSNew.Parent.Close True

ElseIf Mid(cell.Value, 9, 1) = 2 Then
foldername = "I:\Documents\ExcelTen\2\"
WSNew.Parent.SaveAs foldername & cell.Value & FileExtStr,
FileFormatNum
WSNew.Parent.Close True

. . .

Else 'Mid(cell.Value, 9, 1) = 9 Then
foldername = "I:\Documents\ExcelTen\9\"
WSNew.Parent.SaveAs foldername & cell.Value & FileExtStr,
FileFormatNum
WSNew.Parent.Close True
End If '9


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com