Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create a new folder VBA Excel 1

Status
Not open for further replies.

addicted2

MIS
Jan 16, 2002
16
0
0
AU
G'day all.
if someone can help I would greatly appreciate it.
I need a code that will:-
Go to c drive open a folder called household then Create a NEW FOLDER that will be renamed to a name chosen by the user ( maybe via an input box).
I am writting this code for a local Community House where people who cant afford insurance can log their details in a workbook and have it saved into a folder named by them. For ease of use, to much to go into here, there is an average of 3 workbooks per person. This is why I would like to put them into one folder per person.
Thanks
 
Hi,
Here's the code for what you are wanting to do...
Code:
    Dim i, sFolder, UserName
    UserName = InputBox("Please enter your full name.", "Community House Insurance Log")
    sFolder = ""
    For i = 1 To Len(UserName)
        Select Case Mid(UserName, i, 1)
            Case "A" To "z", 0 To 9
                sFolder = sFolder & Mid(UserName, i, 1)
        End Select
    Next
    ChDrive "D"
    ChDir ".."
    ChDir "SkipTest"
    MkDir sFolder  'make new folder as the user's name
Hope this helps ;-) Skip,
metzgsk@voughtaircraft.com
 
This is what I was looking for! but I can't figure out how to include a dash "-" in the folder name (ie. 01-345). If I enter it like this, it ignores the dash, in fact it only takes letters and numbers.

Thanks,
nestor.r.hernandez@boeing.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top