PDA

View Full Version : Solved: Create folders based on values in Column A



ads_3131
10-30-2008, 05:59 AM
Hello, i have tried looking for the answer to this but i cannot find it. What i am wanting to do its all within column A of a speadsheet is input numbers within each cell. e.g(A:1 containing number 23, A:2 containing number 25 etc) as far down with as many random number/text as i want. Then i need a macro which will go into a folder such as c:test and make each cell within column a into a folder within c:test.

So overall once the macro is done i should have as many folders within the c:test folder as within column A of the sheet, also every folder will be named the same as the cell within column A.

Hopefully this is possible, thanks in advance for any help & i have attached a sheet of the layout of what the excel sheet will look like.

Bob Phillips
10-30-2008, 06:02 AM
Doesn't look very random to me.

ads_3131
10-30-2008, 06:38 AM
its just a quick example attached, doesnt matter the number/text within the cell its just a example of the list down column A

Bob Phillips
10-30-2008, 06:46 AM
Public Sub ProcessData()
Const ROOT_FOLDER As String = "C:\myDir\"
Dim LastRow As Long
Dim i As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

On Error Resume Next
For i = 1 To LastRow

MkDir ROOT_FOLDER & .Cells(i, "A").Value
Next i
On erroro GoTo 0
End With

End Sub

ads_3131
10-30-2008, 07:16 AM
THANKS !!! YOU ARE LORD OF VBA lol :D