Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-11-2008, 11:20 AM
streng streng is offline Generate Folder Windows XP Generate Folder Office 2007
Novice
Generate Folder
 
Join Date: Sep 2008
Posts: 11
streng is on a distinguished road
Exclamation Generate Folder

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
Attached Files
File Type: xls Generate Folder.xls (44.0 KB, 30 views)
Reply With Quote
  #2  
Old 07-21-2025, 05:25 PM
Scott Huish Scott Huish is offline Generate Folder Windows 11 Generate Folder Office 2021
Novice
 
Join Date: Jul 2025
Posts: 9
Scott Huish is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 07-21-2025, 08:50 PM
Logit Logit is offline Generate Folder Windows 10 Generate Folder Office 2007
Expert
 
Join Date: Jan 2017
Posts: 591
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

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
Reply With Quote
  #4  
Old 07-21-2025, 11:52 PM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Generate Folder Windows 11 Generate Folder Office 2021
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,943
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

Quote:
Originally Posted by Scott Huish View Post
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.
Almost 17 years later, and not really to the point, is it?
__________________
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
Reply With Quote
  #5  
Old 07-22-2025, 10:49 AM
Scott Huish Scott Huish is offline Generate Folder Windows 11 Generate Folder Office 2021
Novice
 
Join Date: Jul 2025
Posts: 9
Scott Huish is on a distinguished road
Default

I'm not allowed to ask questions? What's wrong with it?
Reply With Quote
  #6  
Old 07-23-2025, 04:56 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Generate Folder Windows 11 Generate Folder Office 2021
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,943
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

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
Reply With Quote
  #7  
Old 07-23-2025, 09:12 PM
Scott Huish Scott Huish is offline Generate Folder Windows 11 Generate Folder Office 2021
Novice
 
Join Date: Jul 2025
Posts: 9
Scott Huish is on a distinguished road
Default

So, I wanted to work on it. So what?
Maybe someone else would find it useful.
Reply With Quote
  #8  
Old 07-23-2025, 09:13 PM
Scott Huish Scott Huish is offline Generate Folder Windows 11 Generate Folder Office 2021
Novice
 
Join Date: Jul 2025
Posts: 9
Scott Huish is on a distinguished road
Default

If you're not allowed to answer questions from the past, they should be deleted from the board.
Reply With Quote
  #9  
Old 07-23-2025, 11:13 PM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Generate Folder Windows 11 Generate Folder Office 2021
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,943
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

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
Reply With Quote
Reply



Other Forums: Access Forums

All times are GMT -7. The time now is 03:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft