VBA creating a folder - combine a set Name and a variable Date

Ughes

New Member
Joined
Jun 6, 2011
Messages
12
Hello All,

Hope this post finds everybody in good order. I have been trawling the forum for some time now, in the hope of finding a specific twist to a common issue - Creating a folder - the code is as simple as it gets. However, as you can see below, I want to create the folder with a set file name PLUS today's date in the following format "yyyymmdd" (no spaces). Not sure how to combine the "IOMR" (set name) with today's date.

Any help that could be given would be mostly appreciated. I know the code just requires a small tweak but cannot get over the finish line.


Sub FolderandFileCreation()

Dim X As Variant
X = Date

MkDir "C:\Documents and Settings\IOMR\IOMR " & X
ActiveWorkbook.SaveAs Filename:="Project Detail for IOMR.xlsm", _
FileFormat:=xlText, CreateBackup:=False

End Sub


Regards to all
Ughes
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try

Code:
MkDir "C:\Documents and Settings\IOMR\IOMR " & Format(X, "yyyymmdd")
 
Upvote 0
Here's one way:

Code:
Sub foo()
Dim x As String

x = Format(Now, "yyyymmdd")


{rest of code here}
 
Upvote 0
Hi Guys,

Lovely stuff, thank you so much for the help.

Knew it was something simple! :stickouttounge:

Ughes
 
Upvote 0

Forum statistics

Threads
1,224,591
Messages
6,179,768
Members
452,940
Latest member
rootytrip

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