ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a directory from a date (https://www.excelbanter.com/excel-programming/271803-creating-directory-date.html)

mark

Creating a directory from a date
 
Here's one way:

Sub test()

Dim stYear As String
Dim stExists As String


stYear = Year(Range("b10").Value)
stExists = Dir("f:\" & stYear, vbDirectory)

If stExists = "" Then

MkDir "f:\" & stYear

End If

End Sub




Tom

Creating a directory from a date
 
Thank you. This worked like a charm. I didn't know about the Year, (and I'm
assuming Day, and Month) functions. I really need to broaden my VBA
vocabulary :).

"mark" wrote in message
...
Here's one way:

Sub test()

Dim stYear As String
Dim stExists As String


stYear = Year(Range("b10").Value)
stExists = Dir("f:\" & stYear, vbDirectory)

If stExists = "" Then

MkDir "f:\" & stYear

End If

End Sub







All times are GMT +1. The time now is 12:13 PM.

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