Excel VBA USERFORMS #16 Auto Format Dates in Textbox

preview_player
Показать описание

As soon as you leave the TB, date will auto fill the full 4 digit year.

Fantastic Developer Tools:
Рекомендации по теме
Комментарии
Автор

Merry Christmas everyone. I hope God blesses you richly this upcoming year. Remember, you ARE a success!! Believe it, be it! Blessings my friends!! Dan

ExcelVbaIsFun
Автор

A most useful feature that can speed up date entry. Many thanks.

PMJugwunth
Автор

Thanks man!  This was super-helpful for a project I'm working on!

BryanGromowski
Автор

sure thing. Instead of using cdate() which uses the format m/d/yyyy, you can say something like this:

instead of

try this:

me.tbStDate=format(me.tbStDate, "mm/yy")


That oughta do it.

ExcelVbaIsFun
Автор

Super welcome, folks. Thank you for watching! Dan

ExcelVbaIsFun
Автор

I like the auto formatting of the date in the textbox. How can we enforce the entry to a specific date format (eg. mm/dd/yyy)?

arlenewillems
Автор

Thank You! I have been trying to figure this out for MONTHS!

I'm wondering how I can do this as part of an If Function...so If CheckBox1 is checked, then Billing_Date value is "See Notes", otherwise, perform this function to format the date.

How can I do that?

KristaBeakleyPamperedChef
Автор

yes, off the top of my head, something like this on the BeforeUpdate event:

if isdate(me.Textbox1) = false then
msgbox "That ain't NO date, yo!"
exit sub
end if

'blah blah other code here
'IF here then they passed the date test above!!



Yours,
Dan

ExcelVbaIsFun
Автор

Nice thanks! I learned something new!
What if I wanted to display dates in the d-mmm-yyyy format, for example I enter 18/1, and the system displays 18-Jan-2021? Or 18/01/2021 in European format? Is this possible? Thank you!

stefanogattoCH
Автор

I have data that prepopulates back into the text box to edit; however, it populates at zip code format and not date. How would I change the text box to display only date format

jfresh
Автор

the code is perfect but i have only one question, how to change display format, with that code it shows 12/31/2017, but what if i want to show it as 31.12.2017?

metalsnake
Автор

thank you so much brother your vid helps a lot! Godbless

philipgargaritano
Автор

Hello ! Thanks for your useful toturials. I appreciate them very much. I would like to know how I can can format textboxes for "hours" and "minutes", for example in a "start hour" and "end hour" ?

JosephArouna
Автор

Great trick Dan as I use CDATE all the time also. It is also very good at converting strings to dates. Try entering apr 1 and CDATE will convert to 1/3/2013.

wmcnabb
Автор

Excellent video and very usefull. Is there a way to convert the date in view to mm/yy?

madogmadson
Автор

I have DTPicker in my form. When I running a macro de format is not date and tried differents way and I'm not able to format it. Can you could help me?
tks
Carlos

carlosferreira
Автор

Hola, muy completa el "rango" de textbox en tu video.
Lo voy a usar en un proyecto de 7 Texbox que tengo.
Pero estoy bucando una macro que el el txtbox de solicitud de "Nombre" me diferencie un texto lógico, digamos "Luis Hernán" y no me acepte algo como "ajklsdfhkl".
La macro que estoy pensando es que no pasen 3 consonantes sin que haya una vocal entre ellas.
¿Conoce alguna? o tenes una idea
Creo que con una macro loop podria ser.
Gracia

Juancabeta
Автор

Hi Dan Is there a way to have a MsgBox pop up if the user does happen to type the wrong date for example 2/31/13

scottmarshburn
Автор

How to enter the dates without typing the Slash("/") ? Or automatically type in the Slash("/") when you type a number? i.e. I type in 12 referring to December then Slash comes out after that... If I type in 13 then nothing comes out... And if you type in a year it automatically corrects the days in February 28th or 29th.... I tried using = "" & "/" & "" & "/" & """"

Ramper
Автор

Sorry I meant it would convert to 1/4/2013...

I guess that's why I use code.

wmcnabb