ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA in Excel 2007, NumberFormat (https://www.excelbanter.com/excel-programming/437741-vba-excel-2007-numberformat.html)

mccann_mj

VBA in Excel 2007, NumberFormat
 
Data entered into a form (in ADD_REP_DATE and ADD_PRD) are in "mm/dd/yyyy"
format, and I'm trying to put them in cells with "mmm-yy" format, but these
statements aren't doing it. I've tried moving the two format statements
before the data entry statements, to no effect.

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"

Also, I recorded a macro for formating the cells, and it came up with
{Selection.NumberFormat = "[$-409]mmm-yy;@"}. Putting this in before or after
the data entry didn't work either. Do I reformat the cells, or ID another
variable with the format? And where can I find how "[$-409]mmm-yy;@" is
broken down?
--
Michael JM

mccann_mj

VBA in Excel 2007, NumberFormat
 
I couldn't find the original thread and reply, until after I posted this. I
have the answer. Thank you all for your time.
--
Michael JM


"mccann_mj" wrote:

Data entered into a form (in ADD_REP_DATE and ADD_PRD) are in "mm/dd/yyyy"
format, and I'm trying to put them in cells with "mmm-yy" format, but these
statements aren't doing it. I've tried moving the two format statements
before the data entry statements, to no effect.

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"

Also, I recorded a macro for formating the cells, and it came up with
{Selection.NumberFormat = "[$-409]mmm-yy;@"}. Putting this in before or after
the data entry didn't work either. Do I reformat the cells, or ID another
variable with the format? And where can I find how "[$-409]mmm-yy;@" is
broken down?
--
Michael JM



All times are GMT +1. The time now is 12:15 PM.

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