How to create a folder in an specific directory with the name on specific cell?

SSF1590

Board Regular
Joined
Oct 20, 2019
Messages
73
Hello,

I am trying to create a code that allows me to create a folder in an specific directory with folder name on textbox1 and if this folder is already created in that directory, it does not allow to create another with the same name. As I am very new to Excel VBA, can you please help me with this code? I do not have any so far, nor I can think on any.

Thank you very much.
 
Last edited:
The only way I can get it to show the "Folder Creation failure" message is if the folder already exists.
What sort of values are you putting in the textbox?
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I agree with you. That is why I do not understand why the folder is not created if the message is telling you it is. But at the same time it does not make since the number generated in textbox1 are different every time.

I am using the code you guys help me with before. I also have that textbook disable, but I already try to made it unable and it still shows me folder creation failure.

Dim x As Long
With Sheets("TARADatabase").Range("A4", Sheets("TARADatabase").Range("A" & Rows.Count).End(xlUp))
x = .Worksheet.Evaluate("max(if(isnumber(--right(" & .Address & ", 3)),--Right(" & .Address & ",3)))")
End With
TextBox1 = "TARA-19-" & Format(x + 1, "000")
TextBox1.Enabled = False

'Debug.Print TextBox1

TextBox2.Value = Application.UserName
TextBox2.Enabled = False
TextBox3.Value = Format(Date, "mm/dd/yyyy")
TextBox3.Enabled = False
 
Last edited:
Upvote 0
If you add this messagebox, what does it say?
Code:
newFolder = TextBox1.Text
[COLOR=#ff0000]MsgBox newFolder
[/COLOR]
path = "C:\Users\SSF1590\Desktop\Tara Project\Folders\" & newFolder
 
Upvote 0
Now that I have added MsgBox newFolder to that line of the code it shows me a blank message. The message shows not text.
 
Upvote 0
In that case it sounds like the textbox is blank.
 
Upvote 0
But the textbox is not empty as I have a code when the form is initialize the number is generated. Is there any way I can fix it so it recognizes the value in the textbox?
 
Upvote 0
I have no idea what is going & cannot recreate it, regardless of whether the textbox is enabled or not.
Double check all your code to ensure that you are not clearing Textbox1 before trying to create the folder.
 
Upvote 0
Thank you so much! You're a genius! That is the issue. I was clearing Textbox1 before creating the folder. It is working now.
Again, thank you very much for all your help on this and your patience! I really appreciate it.
 
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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