Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA in Excel 2007 date formatting

I'm trying to format the cells [1,16] and [1,17] to the "mmm-yy" format. The
user enters the date as "mm/dd/yy" into ADD-REP_DATE and ADD_PRD. I've tried
putting the last two statements above as well, to no effect: the dates still
show up in the cells with the "mm/dd/yy" format. I recorded a macro to change
the format, and came up with {Selection.NumberFormat ="[$-409]mmm-yy;@"}.
Cutting and pasting that didn't work either. The rest of the worksheet uses
the date in the "mmm-yy" format (so does the user).

NEC_SELECT.Offset(I, 0).Cells(1, 16) = Me.ADD_REP_DATE
NEC_SELECT.Offset(I, 0).Cells(1, 17) = Me.ADD_PRD
NEC_SELECT.Offset(I, 0).Cells(1, 16).NumberFormat = "mmm-yy"
NEC_SELECT.Offset(I, 0).Cells(1, 17).NumberFormat = "mmm-yy"

--
Michael JM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default VBA in Excel 2007 date formatting

Hi Michael,

I am assuming that Me.ADD_REP_DATE is a text box and therefore would suggest
that the dates are in text format. Try the following.

NEC_SELECT.Offset(I, 0).Cells(1, 16) = DateValue(Me.ADD_REP_DATE)
NEC_SELECT.Offset(I, 0).Cells(1, 17) = DateValue(Me.ADD_PRD)
NEC_SELECT.Offset(I, 0).Cells(1, 16).NumberFormat = "mmm-yy"
NEC_SELECT.Offset(I, 0).Cells(1, 17).NumberFormat = "mmm-yy"


--
Regards,

OssieMac


"mccann_mj" wrote:

I'm trying to format the cells [1,16] and [1,17] to the "mmm-yy" format. The
user enters the date as "mm/dd/yy" into ADD-REP_DATE and ADD_PRD. I've tried
putting the last two statements above as well, to no effect: the dates still
show up in the cells with the "mm/dd/yy" format. I recorded a macro to change
the format, and came up with {Selection.NumberFormat ="[$-409]mmm-yy;@"}.
Cutting and pasting that didn't work either. The rest of the worksheet uses
the date in the "mmm-yy" format (so does the user).

NEC_SELECT.Offset(I, 0).Cells(1, 16) = Me.ADD_REP_DATE
NEC_SELECT.Offset(I, 0).Cells(1, 17) = Me.ADD_PRD
NEC_SELECT.Offset(I, 0).Cells(1, 16).NumberFormat = "mmm-yy"
NEC_SELECT.Offset(I, 0).Cells(1, 17).NumberFormat = "mmm-yy"

--
Michael JM

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA in Excel 2007 date formatting

Thank you OssieMac! Glad to have somebody to remind me of the basics. And
yes, it worked.
--
Michael JM


"OssieMac" wrote:

Hi Michael,

I am assuming that Me.ADD_REP_DATE is a text box and therefore would suggest
that the dates are in text format. Try the following.

NEC_SELECT.Offset(I, 0).Cells(1, 16) = DateValue(Me.ADD_REP_DATE)
NEC_SELECT.Offset(I, 0).Cells(1, 17) = DateValue(Me.ADD_PRD)
NEC_SELECT.Offset(I, 0).Cells(1, 16).NumberFormat = "mmm-yy"
NEC_SELECT.Offset(I, 0).Cells(1, 17).NumberFormat = "mmm-yy"


--
Regards,

OssieMac


"mccann_mj" wrote:

I'm trying to format the cells [1,16] and [1,17] to the "mmm-yy" format. The
user enters the date as "mm/dd/yy" into ADD-REP_DATE and ADD_PRD. I've tried
putting the last two statements above as well, to no effect: the dates still
show up in the cells with the "mm/dd/yy" format. I recorded a macro to change
the format, and came up with {Selection.NumberFormat ="[$-409]mmm-yy;@"}.
Cutting and pasting that didn't work either. The rest of the worksheet uses
the date in the "mmm-yy" format (so does the user).

NEC_SELECT.Offset(I, 0).Cells(1, 16) = Me.ADD_REP_DATE
NEC_SELECT.Offset(I, 0).Cells(1, 17) = Me.ADD_PRD
NEC_SELECT.Offset(I, 0).Cells(1, 16).NumberFormat = "mmm-yy"
NEC_SELECT.Offset(I, 0).Cells(1, 17).NumberFormat = "mmm-yy"

--
Michael JM

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
Excel 2007: @*. formatting pmetnc Excel Discussion (Misc queries) 15 April 22nd 10 12:19 AM
Conditional formatting of date-cell - 2007 UlfHJensen Excel Discussion (Misc queries) 3 April 21st 10 11:05 AM
How to convert Gregorian date into Hijri Date in Excel 2007? Ahmed Excel Discussion (Misc queries) 2 February 6th 09 03:59 PM
Formatting in Excel 2007 Griffen Excel Discussion (Misc queries) 1 November 11th 08 08:36 AM
Formatting in Excel 2007 pcor New Users to Excel 3 November 21st 07 03:32 AM


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

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"