Create Sub Directories From Excel Column via Macro

T

the_golden_gunman

I have a column in an XLS table, looking like this:

SomeValue1
SomeValue2
SomeValue3

I would like to create a macro that goes through all entries in a
column and if there is a value there, creates a sub-directory in a
speicifed directory.

For example if I specify "C:\Temp" at the top of the Macro, then for
the above example, the following sub-directories will be created:

c:\temp\SomeValue1
c:\temp\SomeValue2
c:\temp\SomeValue3

How could I go about writing such a Macro.

Thanks,

Anil
 
B

Bob Phillips

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Const BASE_DIR As String = "C:\Temp\" '<=== change to suit
Dim i As Long
Dim iLastRow As Long
With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow
MkDir BASE_DIR & .Cells(i, TEST_COLUMN).Value
Next i

End With

End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top