PC Review


Reply
Thread Tools Rate Thread

date based question

 
 
jason
Guest
Posts: n/a
 
      10th Aug 2009
hello,

i need to copy a date formatted as "yyyymmdd" (preferably as a
string).
each time i copy it, i copy the mm/dd/yyyy format when i copy cells
(x,y).value or any other form.

any tips would be a huge help
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      10th Aug 2009
Since you posted to a programming newsgroup, I assume your question is
asking for a VB solution... use the Text property of the Range or Cells
objects to get the text that is in the cell instead of its underlying value.
For example, if A1 contains a date formatted as you indicated, then this
will copy the displayed text into the cell B1...

Range("B1").Valued = Range("A1").Text

--
Rick (MVP - Excel)


"jason" <(E-Mail Removed)> wrote in message
news:af009d7d-3efd-494d-8e81-(E-Mail Removed)...
> hello,
>
> i need to copy a date formatted as "yyyymmdd" (preferably as a
> string).
> each time i copy it, i copy the mm/dd/yyyy format when i copy cells
> (x,y).value or any other form.
>
> any tips would be a huge help


 
Reply With Quote
 
jason
Guest
Posts: n/a
 
      10th Aug 2009
On Aug 10, 11:30*am, "Rick Rothstein"
<rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> Since you posted to a programming newsgroup, I assume your question is
> asking for a VB solution... use the Text property of the Range or Cells
> objects to get the text that is in the cell instead of its underlying value.
> For example, if A1 contains a date formatted as you indicated, then this
> will copy the displayed text into the cell B1...
>
> Range("B1").Valued = Range("A1").Text
>
> --
> Rick (MVP - Excel)
>
> "jason" <jason.mell...@gmail.com> wrote in message
>
> news:af009d7d-3efd-494d-8e81-(E-Mail Removed)...
>
>
>
> > hello,

>
> > i need to copy a date formatted as "yyyymmdd" (preferably as a
> > string).
> > each time i copy it, i copy the mm/dd/yyyy format when i copy cells
> > (x,y).value or any other form.

>
> > any tips would be a huge help- Hide quoted text -

>
> - Show quoted text -


very great.
thanks
 
Reply With Quote
 
jason
Guest
Posts: n/a
 
      10th Aug 2009
On Aug 10, 11:30*am, "Rick Rothstein"
<rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> Since you posted to a programming newsgroup, I assume your question is
> asking for a VB solution... use the Text property of the Range or Cells
> objects to get the text that is in the cell instead of its underlying value.
> For example, if A1 contains a date formatted as you indicated, then this
> will copy the displayed text into the cell B1...
>
> Range("B1").Valued = Range("A1").Text
>
> --
> Rick (MVP - Excel)
>
> "jason" <jason.mell...@gmail.com> wrote in message
>
> news:af009d7d-3efd-494d-8e81-(E-Mail Removed)...
>
>
>
> > hello,

>
> > i need to copy a date formatted as "yyyymmdd" (preferably as a
> > string).
> > each time i copy it, i copy the mm/dd/yyyy format when i copy cells
> > (x,y).value or any other form.

>
> > any tips would be a huge help- Hide quoted text -

>
> - Show quoted text -


exactly what i need.
thanks
 
Reply With Quote
 
jason
Guest
Posts: n/a
 
      11th Aug 2009
On Aug 10, 12:15*pm, jason <jason.mell...@gmail.com> wrote:
> On Aug 10, 11:30*am, "Rick Rothstein"
>
>
>
>
>
> <rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> > Since you posted to a programming newsgroup, I assume your question is
> > asking for a VB solution... use the Text property of the Range or Cells
> > objects to get the text that is in the cell instead of its underlying value.
> > For example, if A1 contains a date formatted as you indicated, then this
> > will copy the displayed text into the cell B1...

>
> > Range("B1").Valued = Range("A1").Text

>
> > --
> > Rick (MVP - Excel)

>
> > "jason" <jason.mell...@gmail.com> wrote in message

>
> >news:af009d7d-3efd-494d-8e81-(E-Mail Removed)....

>
> > > hello,

>
> > > i need to copy a date formatted as "yyyymmdd" (preferably as a
> > > string).
> > > each time i copy it, i copy the mm/dd/yyyy format when i copy cells
> > > (x,y).value or any other form.

>
> > > any tips would be a huge help- Hide quoted text -

>
> > - Show quoted text -

>
> exactly what i need.
> thanks- Hide quoted text -
>
> - Show quoted text -


actually not working.

code:
dim q
q=1
cells(2,2)=1
cells(3,2)=1
cells(4,3)=2009




Worksheets("Sheet1").Cells(5, q + 1) = Worksheets
("Sheet1").Cells(2, q + 1) & "/" & Worksheets("Sheet1").Cells(3, q +
1) & "/" & Worksheets("Sheet1").Cells(4, q + 1)
Worksheets("Sheet1").Cells(5, q + 1).NumberFormat = "m/d/
yy;@"
Worksheets("Sheet1").Cells(6, q + 1).Value = Worksheets
("Sheet1").Cells(5, q + 1).Text
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      11th Aug 2009
For the example you gave, this cell...

Worksheets("Sheet1").Cells(4, q + 1)

has nothing in it. I think the problem goes back to this statement...

Cells(4, 3) = 2009

In particular, the 3... your previous statements use 2 for the column. Was
the 3 a mistake? If you change it to 2, the code you posted appears to work
correctly.

As an unrelated aside, you should consider prefacing all the cell references
with your worksheet reference, not just some of them.

--
Rick (MVP - Excel)


"jason" <(E-Mail Removed)> wrote in message
news:95c23565-58cf-4ad6-8cb8-(E-Mail Removed)...
On Aug 10, 12:15 pm, jason <jason.mell...@gmail.com> wrote:
> On Aug 10, 11:30 am, "Rick Rothstein"
>
>
>
>
>
> <rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> > Since you posted to a programming newsgroup, I assume your question is
> > asking for a VB solution... use the Text property of the Range or Cells
> > objects to get the text that is in the cell instead of its underlying
> > value.
> > For example, if A1 contains a date formatted as you indicated, then this
> > will copy the displayed text into the cell B1...

>
> > Range("B1").Valued = Range("A1").Text

>
> > --
> > Rick (MVP - Excel)

>
> > "jason" <jason.mell...@gmail.com> wrote in message

>
> >news:af009d7d-3efd-494d-8e81-(E-Mail Removed)...

>
> > > hello,

>
> > > i need to copy a date formatted as "yyyymmdd" (preferably as a
> > > string).
> > > each time i copy it, i copy the mm/dd/yyyy format when i copy cells
> > > (x,y).value or any other form.

>
> > > any tips would be a huge help- Hide quoted text -

>
> > - Show quoted text -

>
> exactly what i need.
> thanks- Hide quoted text -
>
> - Show quoted text -


actually not working.

code:
dim q
q=1
cells(2,2)=1
cells(3,2)=1
cells(4,3)=2009




Worksheets("Sheet1").Cells(5, q + 1) = Worksheets
("Sheet1").Cells(2, q + 1) & "/" & Worksheets("Sheet1").Cells(3, q +
1) & "/" & Worksheets("Sheet1").Cells(4, q + 1)
Worksheets("Sheet1").Cells(5, q + 1).NumberFormat = "m/d/
yy;@"
Worksheets("Sheet1").Cells(6, q + 1).Value = Worksheets
("Sheet1").Cells(5, q + 1).Text

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about ordering columns based on date Schizoid Man Microsoft Excel Discussion 5 13th Oct 2008 04:26 PM
Sumproduct based which also weights data based on date =?Utf-8?B?RXhjZWxNb25rZXk=?= Microsoft Excel Worksheet Functions 6 4th Feb 2007 08:51 AM
copy date based on date -refer to date range mindpeace Microsoft Excel Programming 1 3rd Jun 2006 01:30 PM
Update cell based on date range - noob question deversole Microsoft Excel Discussion 8 8th Jul 2005 02:00 PM
Startup Question based on date Stephen Lynch Microsoft Access VBA Modules 3 17th Feb 2005 05:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:12 AM.