![]() |
|
#1
|
|||
|
|||
|
Hi There,
I hope someone can help as I am a bit above my head here and would realy appreciate some help. I have attached a mock up of what I am trying to achieve. I am trying to generate a folder within a specific location (For now lets call it C:\Jobs\) that will be named as per the adjacent cell (Column H on attached) Obviously if the folder already exists I want the code to stop. But this code will have to generate a different folder for each row within the spreadsheet. Hope someone can help Streng |
|
#2
|
|||
|
|||
|
You probably don't need an answer to this anymore, but your formula definitely can be shortened to this:
=IF(D6="","",CONCATENATE("F08.",TEXT(G6,"000")," - ",D6,", ",E6)) Kinda curious why you have buttons for creating the folders on each line as opposed to just running through them all. |
|
#3
|
|||
|
|||
|
Code:
Sub GenerateFoldersFromColumnH()
Dim ws As Worksheet
Dim lastRow As Long
Dim folderName As String
Dim folderPath As String
Dim i As Long
' Set your target worksheet
Set ws = ThisWorkbook.Sheets("Sheet1") ' Rename if needed
' Find the last used row in column H
lastRow = ws.Cells(ws.Rows.Count, "H").End(xlUp).Row
' Loop through each row in column H
For i = 2 To lastRow ' Start from row 2 assuming row 1 is a header
folderName = Trim(ws.Cells(i, "H").Value)
' Skip blank folder names
If folderName <> "" Then
folderPath = " C:\Jobs\" & folderName
' Check if folder exists
If Dir(folderPath, vbDirectory) = "" Then
MkDir folderPath
Else
MsgBox "Folder already exists for: " & folderName, vbInformation, "Duplicate Folder"
Exit Sub
End If
End If
Next i
End Sub
|
|
#4
|
||||
|
||||
|
Quote:
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
|
#5
|
|||
|
|||
|
I'm not allowed to ask questions? What's wrong with it?
|
|
#6
|
||||
|
||||
|
OP connected last time in July 2009. I really doubt (s)he is still following the thread
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
|
#7
|
|||
|
|||
|
So, I wanted to work on it. So what?
Maybe someone else would find it useful. |
|
#8
|
|||
|
|||
|
If you're not allowed to answer questions from the past, they should be deleted from the board.
|
|
#9
|
||||
|
||||
|
Who am I to say if you are allowed or not to do things on this board? Just pointing out that in post #2 you seem to be asking a question to an OP that has not been on the board for 16 years
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
|
|
|