ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date format using VBA (https://www.excelbanter.com/excel-programming/277168-date-format-using-vba.html)

Jeff[_21_]

Date format using VBA
 
I would like to format a range of cells using VBA to only
accept the mm/dd/yy date format. Also, is it possible to
pre-populate each of those cells where the user would
see " / / " and they just fill in the spaces?

Tom Ogilvy

Date format using VBA
 
Sounds like a bad idea. Dates are not stored as mm/dd/yy - they are stored
as a number of days from a base date. So any valid date format is
acceptable - Excel will see this as a date and generate the date serial.
You can format the cell to show mm/dd/yy format - but it is counter
productive to try to force the user to enter the data in a specific format.

If you put a zero in the cell it will display as

00/00/00
But that is about as close to / / as you can get unless you either put in
/ / manually or produced it with a formula and in either case, it would
get overwritten by the user making an entry.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
I would like to format a range of cells using VBA to only
accept the mm/dd/yy date format. Also, is it possible to
pre-populate each of those cells where the user would
see " / / " and they just fill in the spaces?





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

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