ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create new directory (https://www.excelbanter.com/excel-programming/343299-create-new-directory.html)

Francis Brown

Create new directory
 
Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.

Jim Thomlinson[_4_]

Create new directory
 
mkDir "C:\Datefile\" & format(sheets("MainPage").range("C22").Value, _
"yyyy-mm-dd")

Off the top of my head that should be close.
--
HTH...

Jim Thomlinson


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.


sebastienm

Create new directory
 
Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.


Jim Thomlinson[_4_]

Create new directory
 
Sebastien brings up an interesting point. If the value in C22 is a text
string then use his code to replace the slashes with dashes. If however, as I
had assumed, the value is a date then the replace will not work and my code
will... Depend on what you have...
--
HTH...

Jim Thomlinson


"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.


Bob Phillips[_6_]

Create new directory
 
Jim,

The text property of a range object is a text string, even if the value is a
date. It returns the cell as formatted. Your way is better though IMO as it
formats the date year first, which is better for sorting.

Bob

"Jim Thomlinson" wrote in message
...
Sebastien brings up an interesting point. If the value in C22 is a text
string then use his code to replace the slashes with dashes. If however,

as I
had assumed, the value is a date then the replace will not work and my

code
will... Depend on what you have...
--
HTH...

Jim Thomlinson


"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a

cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile

folder.

Thanks in advance.

Francis.




Jim Thomlinson[_4_]

Create new directory
 
I didn't notice that Sebastien had used Text... I just assumed Value (which I
always use). I never use text for stuff like that because my end users like
to change formats and such on me. I guess that my end users are a little more
fiendish and clever than I would like... I will have to be more careful in
the future...

Nice catch Bob
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

Jim,

The text property of a range object is a text string, even if the value is a
date. It returns the cell as formatted. Your way is better though IMO as it
formats the date year first, which is better for sorting.

Bob

"Jim Thomlinson" wrote in message
...
Sebastien brings up an interesting point. If the value in C22 is a text
string then use his code to replace the slashes with dashes. If however,

as I
had assumed, the value is a date then the replace will not work and my

code
will... Depend on what you have...
--
HTH...

Jim Thomlinson


"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a

cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile

folder.

Thanks in advance.

Francis.





Francis Brown

Create new directory
 
This Method worked.

Regards and Thanks.

Francis.

"Jim Thomlinson" wrote:

mkDir "C:\Datefile\" & format(sheets("MainPage").range("C22").Value, _
"yyyy-mm-dd")

Off the top of my head that should be close.
--
HTH...

Jim Thomlinson


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.


Bob Phillips[_6_]

Create new directory
 
It is quite a useful property to have up your sleeve Jim.

I still prefer your method :-))

Bob


"Jim Thomlinson" wrote in message
...
I didn't notice that Sebastien had used Text... I just assumed Value

(which I
always use). I never use text for stuff like that because my end users

like
to change formats and such on me. I guess that my end users are a little

more
fiendish and clever than I would like... I will have to be more careful in
the future...

Nice catch Bob
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

Jim,

The text property of a range object is a text string, even if the value

is a
date. It returns the cell as formatted. Your way is better though IMO as

it
formats the date year first, which is better for sorting.

Bob

"Jim Thomlinson" wrote in message
...
Sebastien brings up an interesting point. If the value in C22 is a

text
string then use his code to replace the slashes with dashes. If

however,
as I
had assumed, the value is a date then the replace will not work and my

code
will... Depend on what you have...
--
HTH...

Jim Thomlinson


"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a

cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in

C:/Datefile
folder.

Thanks in advance.

Francis.







maperalia

Create new directory
 
Sebastienm;
I wonder if you can help me to setup this macro. I want to create a
directory when I save as my file. My macro (see below) save as the file under
specific directory. However, I want to create a directory with the same
filename which is the description typed in the cell "C1" on the the sheet
"Test" and put my file under this new directory.
Could you please help me with this matter.
Thanks in advance.

Maperalia



'*** START MACRO *****
Sub SaveAs()
Dim WO As String

Set swApp = Application.SldWorks
Set swApp = GetObject("SldWorks.Application")
Set Part = swApp.ActiveDoc

WO = Worksheets("Test").Range("C1")
longstatus = Part.SaveAs3("C:\Table\Top\ " & WO & ".sldprt", 0, 2)
End Sub
'*** END MACRO *****

"sebastienm" wrote:

Francis,
you can use the mkdir statement. SOmething like (no tested):
'-----------------------------------
Dim s as string, path as string

path= "C:/Datefile/"

s=ThisWorksbook.sheets("MainPage").Range("C22").Te xt
s = replace(s, "/", "-") ' replace / with dash -

path= path & s ' <------ path string
makdir path
'------------------------------
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Francis Brown" wrote:

Hello.

How to you create a directory named the same as a date stored in a cell.

say sheet MainPage has a date 25/10/2005 in cell C22.

How do you take this and make a Direcotry 22-10-2005 in C:/Datefile folder.

Thanks in advance.

Francis.



All times are GMT +1. The time now is 09:02 PM.

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