Place newly updated file into specific folder on network drive

skidda420

New Member
Joined
Jun 7, 2018
Messages
26
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello all,
I have done much digging in order to get this far but I'm still in little bit of a pickle. I am trying to make it so if a cell I have has a specific number form that it will save to a specific folder. In the Cell (L1) I have the date set as "mm-dd-yyyy hh-mm" and machine number ("11D, 12D, 13D"). When I save the file it looks like this "8-9-2021 9-38 11D", which is perfect. However I am trying to find a way to direct the file depending on the machine (11D, 12D, 13D) into their own separate folders. This is the VBA I am using through a button click at the moment. Ignore the path, I'm just using it for testing purposes. Any suggestions or help is much appreciated. Thank you in advance.


Private Sub CommandButton1_Click()
Dim path As String
Dim filename1 As String
path = "\\DESKTOP-9IK993S\2TB Download Drive\Torrents\"
filename1 = Range("L1").Text
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs filename:=path & filename1 & ".xlsx", FileFormat:=xlOpenXMLWorkbook
Application.DisplayAlerts = True
Application.Quit
End Sub
 
this is what came from the culmination and so far it works
VBA Code:
Sub Save_and_Close()
Dim Folder As String
Dim Filename As String
Filename = Range("L2").Text
Folder = "D:\Production\MachineTender\" & Format(Date, "mmm") & "\"
On Error Resume Next
MkDir Folder
On Error GoTo 0
With ActiveWorkbook
.SaveAs Filename:=Folder & Filename
End With
Application.Quit
End Sub
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
when you say location I'm assuming that's the sheets name correct? or the folder location? Now I'm a little confused lol. So it would be making its own separate directory within the file system?
Only check the name part as to how I have named the folder / file in date format

Dim valuedate As String
valuedate = (Format(Date, "dd-mm-yyyy"))
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,119
Members
452,381
Latest member
Nova88

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