ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create folder with a macro (https://www.excelbanter.com/excel-programming/302742-create-folder-macro.html)

Myrna Rodriguez

Create folder with a macro
 
Hi...

I'm on a VB mission to create a folder based on cells in
"Column A". A folder will be created when user executes
OK commandbutton which will filter data on excel worksheet.


I was successful in creating a folder with defining one range ("A1").
However, I get stuck when specifying multiple ranges. I tried "A:A",
"A1:A65353".
Any suggestions how I got stuck with a bug??

This is the code I'm using in the OK Command Button.

Dim x As String
x = "S:\Employee Folders\" & Range("A1:A65535")
On Error Resume Next
MkDir x

I'm getting this error: Type Mismatch

Thanks for your helping hand!
Myrna


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Bob Phillips[_6_]

Create folder with a macro
 

Dim x As String
Dim cell As Range

On Error Resume Next

cLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For Each cell in Range("A1:A" & cLastRow)
x = "S:\Employee Folders\" & cell.Value
MkDir x
NExt cell

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Myrna Rodriguez" wrote in message
...
Hi...

I'm on a VB mission to create a folder based on cells in
"Column A". A folder will be created when user executes
OK commandbutton which will filter data on excel worksheet.


I was successful in creating a folder with defining one range ("A1").
However, I get stuck when specifying multiple ranges. I tried "A:A",
"A1:A65353".
Any suggestions how I got stuck with a bug??

This is the code I'm using in the OK Command Button.

Dim x As String
x = "S:\Employee Folders\" & Range("A1:A65535")
On Error Resume Next
MkDir x

I'm getting this error: Type Mismatch

Thanks for your helping hand!
Myrna


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!




Myrna Rodriguez

Create folder with a macro
 

Hi Bob~

Thanks so much! You're a magician...
The code works successfully.
Curious? what does HTH stands for in your signature?
thanks!
Myrna


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Bob Phillips[_6_]

Create folder with a macro
 
Hope This Helps<g

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Myrna Rodriguez" wrote in message
...

Hi Bob~

Thanks so much! You're a magician...
The code works successfully.
Curious? what does HTH stands for in your signature?
thanks!
Myrna


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 05:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com