Modify Ron de Bruin Code; Save Specific Files to Specific Folders

R

ryguy7272

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

ryguy7272

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) andif
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top