My Target value is 'Test' My Workbook is located in the folder 'SERVICE PROVIDERS' The…
- User
My Target value is 'Test' My Workbook is located in the folder 'SERVICE PROVIDERS' The folder 'SERVICE PROVIDERS' is within a folder 'PREMISES'. When I run the code below, it is creating a folder in the 'PREMISES' folder and naming this new folder 'SERVICE PROVIDERSTest'. What I actually want it to do is to create a folder within the folder 'SERVICE PROVIDERS' and name this new folder as 'Test'
If Target.Column = 3 Then contractorName = Target.Value Dim Path As String Path = ThisWorkbook.Path & contractorName If Dir(Path, vbDirectory) = "" Then MkDir Path
- Assistant
To achieve the desired result, you can modify the code by adding a backslash ("") after the folder name "SERVICE PROVIDERS" in the Path variable, and then concatenate the target value "Test" after the backslash. This will create a folder named "Test" within the "SERVICE PROVIDERS" folder. Here's the updated code:
vbaIf Target.Column = 3 Then contractorName = Target.Value Dim Path As String Path = ThisWorkbook.Path & "\SERVICE PROVIDERS\" & contractorName If Dir(Path, vbDirectory) = "" Then MkDir Path End If End IfThis code will create a folder named "Test" within the "SERVICE PROVIDERS" folder in the current directory of the workbook.