Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Date-Text Format

I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving the
file. Any suggestions appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Date-Text Format



"Bigfoot17" wrote:

I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving the
file. Any suggestions appreciated.


try strDate = Format(Range("Buttons!B4").Value,"mmddyy")

You could then use strDate in your file name: "Prefix" & strDate & ".xls"

This would concatenate a file name of Prefix120508.xls

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default Date-Text Format

You cannot format it that way but you can generate text with value 120508
using formula
=TEXT(MONTH(B3),"00")&(TEXT(DAY(B3),"00")&TEXT(MOD (YEAR(B3),1000),"00"))
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Bigfoot17" wrote in message
...
I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to
show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving
the
file. Any suggestions appreciated.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Date-Text Format

On Dec 5, 2:13*pm, Bigfoot17
wrote:
I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving the
file. *Any suggestions appreciated.


Right click on the cell and choose format cells. Then choose Custom
as your format and for type, type in 'mmddyy'
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Date-Text Format

Hi,

Apply a custom format of

mmddyy

You will have to refer to it as

ActiveSheet.Name = Range("A1").Text

using .value will give an error

Mike


"Bigfoot17" wrote:

I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving the
file. Any suggestions appreciated.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Date-Text Format

Leave the date in it but change the format to mmddyy

--
Rick (MVP - Excel)


"Bigfoot17" wrote in message
...
I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to
show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving
the
file. Any suggestions appreciated.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default Date-Text Format

Oh dear, I was very wrong! Should have tried before answering!
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Bernard Liengme" wrote in message
...
You cannot format it that way but you can generate text with value 120508
using formula
=TEXT(MONTH(B3),"00")&(TEXT(DAY(B3),"00")&TEXT(MOD (YEAR(B3),1000),"00"))
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Bigfoot17" wrote in message
...
I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to
show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving
the
file. Any suggestions appreciated.





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Date-Text Format

It seems things got off track on this one, which means I wasn't clear enough.
Several suggestions are telling me how to format the cell. Well, I posted
this in the programming section because I am trying to understand how I can
manipulate the contents of the cell. The data is place in the cell in the
format that is needed there, but I want to use this date elsewhere in VBA.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Date-Text Format

Using cdate=Range("D6").Text gives me "5-Dec" and I am assuming that is
because the cell is formatted that way. I am trying to extract a 6-character
string no matter what the date. [i.e., "1-Jan" would yield "010108"].

Bernard Liengme seemed to be heading where I wanted to go and then retracted
his suggestion.

"Mike H" wrote:

Hi,

Apply a custom format of

mmddyy

You will have to refer to it as

ActiveSheet.Name = Range("A1").Text

using .value will give an error

Mike


"Bigfoot17" wrote:

I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving the
file. Any suggestions appreciated.

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Date-Text Format



"Bigfoot17" wrote:

It seems things got off track on this one, which means I wasn't clear enough.
Several suggestions are telling me how to format the cell. Well, I posted
this in the programming section because I am trying to understand how I can
manipulate the contents of the cell. The data is place in the cell in the
format that is needed there, but I want to use this date elsewhere in VBA.


I stand by my suggestion.


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Date-Text Format

Dim myStr as string
mystr = format(worksheets("buttons").range("B4").value,"mm ddyy")


Bigfoot17 wrote:

I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving the
file. Any suggestions appreciated.


--

Dave Peterson
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Date-Text Format

Use this instead

as I said in my last post on the worksheet format as
mmddyyyy

then use

mytext = Range("D6").Text
ActiveSheet.Name = mytext


or leave the worksheet date formatted as mm/dd/yy and in the code use

mytext = Format(Range("D6").Text, "mmddyyyy")
ActiveSheet.Name = mytext

using cdate as the variable won't work

Mike


"Bigfoot17" wrote:

Using cdate=Range("D6").Text gives me "5-Dec" and I am assuming that is
because the cell is formatted that way. I am trying to extract a 6-character
string no matter what the date. [i.e., "1-Jan" would yield "010108"].

Bernard Liengme seemed to be heading where I wanted to go and then retracted
his suggestion.

"Mike H" wrote:

Hi,

Apply a custom format of

mmddyy

You will have to refer to it as

ActiveSheet.Name = Range("A1").Text

using .value will give an error

Mike


"Bigfoot17" wrote:

I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving the
file. Any suggestions appreciated.

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Date-Text Format

Dates are stored in VBA the same way as in Excel... as a Double. The integer
portion of the date represents the number of days from "date zero" (which in
VB is 12/30/1899) and the decimal portion of the number is the fraction of a
24-hour day. The best way to work with dates in VB is to keep them in a
variable Dim'med as Date and to use the various Date functions that VB
provides to manipulate them. The format of the Date, for example your mmddyy
format would be produced from the Format function, something like this as an
example...

FileName = "My File Dated " & Format(DateVariable, "mmddyy") & ".txt"

--
Rick (MVP - Excel)


"Bigfoot17" wrote in message
...
It seems things got off track on this one, which means I wasn't clear
enough.
Several suggestions are telling me how to format the cell. Well, I posted
this in the programming section because I am trying to understand how I
can
manipulate the contents of the cell. The data is place in the cell in the
format that is needed there, but I want to use this date elsewhere in VBA.


  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Date-Text Format

And this looks a lot like the first suggestion you got from LWD3.

Dave Peterson wrote:

Dim myStr as string
mystr = format(worksheets("buttons").range("B4").value,"mm ddyy")

Bigfoot17 wrote:

I have a cell (Buttons!B4) that has a date (12/5/08) in it formatted to show
as 5-Dec.

What I would like to do is have this date, or any date in this cell, as a
6-digit text string (120508) so I can use it in the file name when saving the
file. Any suggestions appreciated.


--

Dave Peterson


--

Dave Peterson
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
Need help with converting CUSTOM format/TEXT format to DATE format Deo Cleto Excel Worksheet Functions 6 June 2nd 09 08:14 PM
Convert date from text format to date format Anita Excel Discussion (Misc queries) 3 June 4th 07 11:57 AM
Convert date + time text format to date format Paul Ho Excel Worksheet Functions 2 May 22nd 07 05:47 PM
code to convert date from TEXT format (03-02) to DATE format (200203) Gauthier[_2_] Excel Programming 0 September 22nd 04 03:26 PM
Change a date in text format xx.xx.20xx to a recognised date format concatenator Excel Programming 1 November 24th 03 11:33 PM


All times are GMT +1. The time now is 04:36 PM.

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

About Us

"It's about Microsoft Excel"