Date format using VBA

J

Jeff

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?
 
T

Tom Ogilvy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top