[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Create A New Folder Using VBA and Excel Cell Reference for Folder Name

Posted on 2009-12-21
4
Medium Priority
?
764 Views
Last Modified: 2012-06-27
Is it possible to create a new folder where the path name is in an Excel cell?  Also, the folder name would be the current date in this format, "YYYYMMDD".
0
Comment
Question by:error_prone
  • 2
  • 2
4 Comments
 
LVL 59

Accepted Solution

by:
Saurabh Singh Teotia earned 2000 total points
ID: 26099273
Assuming you have path in cell A1, then you can use the following code, Also to use the code you need to have microsoft scripting runtime library selected, To do that in vb editor go to tools-->references and search for the library and add it.
Saurabh...

Sub checkfolder()
    Dim xdir As String
    Dim objfile As Object

    xdir = Range("A1").Value & "\" & Format(Now(), "yyyymmdd")

    Set objfile = New FileSystemObject

    If objfile.FolderExists(xdir) Then

        MsgBox "Folder Exists"
    Else
        MkDir xdir
        MsgBox "Folder created"
    End If





End Sub

Open in new window

0
 

Author Comment

by:error_prone
ID: 26099292
How do I change the msg "Folder Exists" to basically have it keep going?  Type in Resume Next?
0
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 26099305
Enter your code after end if that is after line-16 and it will keep on going the code after the message and if you want to remove the message then change the line-11 that is completely remove it which will remove the message.
Saurabh...
0
 

Author Closing Comment

by:error_prone
ID: 31668683
Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question