Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel macro to create directories?

Hi,

New around here and not much of a VBA programmer, but hope you can help me
out.

I want to create a macro in Excel that will use the MkDir function to create
directories based on values contained in two columns. The values in Column A
define the 1st level directory and those in Column B define the 2nd level
directory.

For example:

The following data in columns A and B of the spreadsheet:

A B
one aaaa
one bbbb
one cccc
two dddd
two eeee
two ffff

Would create the following directories:

€¦\one\aaaa
€¦\one\bbbb
€¦\one\ccc

€¦\two\dddd
€¦\two\eeee
€¦\two\ffff

Any help would be greatly appreciated!

--
Thanks,
Tom

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Excel macro to create directories?

For i = 1 To Cells(Rows.Countr,"A").End(xlUp).Row
On Error Resume Next
MkDir "C:\" & Cells(i,"A").Value
On Error Goto 0
MkDir "C:\" & Cells(i,"A").Value & "\" & Cells(i,"B"),Value
Next i

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"TomK" <u28588@uwe wrote in message news:68b02809d8354@uwe...
Hi,

New around here and not much of a VBA programmer, but hope you can help me
out.

I want to create a macro in Excel that will use the MkDir function to

create
directories based on values contained in two columns. The values in

Column A
define the 1st level directory and those in Column B define the 2nd level
directory.

For example:

The following data in columns A and B of the spreadsheet:

A B
one aaaa
one bbbb
one cccc
two dddd
two eeee
two ffff

Would create the following directories:

.\one\aaaa
.\one\bbbb
.\one\ccc

.\two\dddd
.\two\eeee
.\two\ffff

Any help would be greatly appreciated!

--
Thanks,
Tom



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel macro to create directories?

Thanks for the reply Bob. I tried your code, but got a runtime error on the
first line.

€śRuntime error 438: Object doesnt support this property or method.€ť

Here is what I ran:

Sub test()

For i = 1 To Cells(Rows.Countr, "A").End(xlUp).Row
On Error Resume Next
MkDir "C:\test\" & Cells(i, "A").Value
On Error GoTo 0
MkDir "C:\test\" & Cells(i, "A").Value & "\" & Cells(i, "B").Value
Next i

End Sub


Bob Phillips wrote:
For i = 1 To Cells(Rows.Countr,"A").End(xlUp).Row
On Error Resume Next
MkDir "C:\" & Cells(i,"A").Value
On Error Goto 0
MkDir "C:\" & Cells(i,"A").Value & "\" & Cells(i,"B"),Value
Next i

Hi,

[quoted text clipped - 29 lines]

Any help would be greatly appreciated!


--
Thanks,
Tom

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel macro to create directories?

Never mind, I found the typo (doh!).
Thanks Bob! Works like a champ!

TomK wrote:
Thanks for the reply Bob. I tried your code, but got a runtime error on the
first line.

€śRuntime error 438: Object doesnt support this property or method.€ť

Here is what I ran:

Sub test()

For i = 1 To Cells(Rows.Countr, "A").End(xlUp).Row
On Error Resume Next
MkDir "C:\test\" & Cells(i, "A").Value
On Error GoTo 0
MkDir "C:\test\" & Cells(i, "A").Value & "\" & Cells(i, "B").Value
Next i

End Sub

For i = 1 To Cells(Rows.Countr,"A").End(xlUp).Row
On Error Resume Next

[quoted text clipped - 8 lines]

Any help would be greatly appreciated!



--
Thanks,
Tom

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a macro to create excel line graph with coloured pointers anddata lables anuj datta Charts and Charting in Excel 1 September 30th 09 04:04 PM
Create list from directories SoloGIS Excel Discussion (Misc queries) 1 November 22nd 05 09:01 AM
Create Windows Directories from column entries? || cypher || Excel Discussion (Misc queries) 2 July 22nd 05 04:11 PM
Create Windows Directories from column entries? || cypher || Excel Worksheet Functions 2 July 22nd 05 04:11 PM
Creating directories from excel Jean-Yves[_2_] Excel Programming 1 August 27th 04 05:22 PM


All times are GMT +1. The time now is 01:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"