K Bizzy
K Bizzy

Reputation: 85

Moving file to dynamic folder

Hi I am currently working on a spreadsheet that generates a file and saves it on a certain folder, but the folders change per job number. currently i set the destination folder as my Desktop and I manually move the file to required folder. Here is my code below:

Sub Move ()
Dim FSO As Object
Dim SourceFileName, DestinFileFolder As String

Set FSO = CreateObject("Scripting.Filesystemobject")
SourceFileName = "Z:\USERS\KweziM\PROJECT S\FUILD COOLERS STANDARD UPL1.pdf"
DestinFileFolder = "C:\Users\Kwezim\Desktop\"

FSO.MoveFile Source:=SourceFileName, Destination:=DestinFileFolder

MsgBox (SourceFileName + " Moved to " + DestinFileFolder)

End Sub

The Folder name changes each time and the name is linked to cell E8 in Sheet 1. Please assist

Upvotes: 1

Views: 547

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149287

The Folder name changes each time and the name is linked to cell E8 in Sheet 1.

DestinFileFolder = ThisWorkbook.Sheets("Sheet1").Range("E8").Value

Upvotes: 1

Related Questions