Create a new folder as generate a column at the same time with submission

Monica_hey

New Member
Joined
Jun 6, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi guys,

I am new to VBA. Working on a simple data input userform. Need some help with on function. Appreciate your input!!

My goal is to:
(1) Create my column A with the data input from user (this is done and working ok, only that I need to number it if the same date already exists);
(2) Create a folder with the value of the created column A.

Code is as below. Problem is that I need a suffix at the end of column A if the same date already exists. And folder is outside of the current folder, need it to be at the same folder.

Thank you for your help!
________________________
ws1.Range("A" & i) = pj_nm_bx.Value & "-" & pr_nm_bx.Value & "-" & arr & "-0"

pth = Application.ThisWorkbook.Path

Set FileSystem = CreateObject("Scripting.FileSystemObject")

For n = 1 To 100
If 0 < Application.WorksheetFunction.CountIf(Sheets("TicketList").Range("A:A"), ws1.Range("A" & i)) < n Then
ws1.Range("A" & i) = ws1.Range("A" & i) & n

Else
ws1.Range("A" & i) = ws1.Range("A" & i) & (n + 1)


End If
newFolder = ws1.Range("A" & i)
If Dir(pth & newFolder, vbDirectory) = "" Then
MkDir pth & newFolder
End If

Exit For

Next


Range("A" & i) = Range("A" & i) & t
'folderNm = Range("A" & i)
newFolder = Range("A" & i)

FileSystem.CreateFolder (newFolder)
 

Attachments

  • 1.jpg
    1.jpg
    14.9 KB · Views: 3

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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