Very cool tricks. I would have been busy googling to get the keyval codes, I will put your trick of getting the parameter value by hovering the mouse over it a ton!!!
Thanks, Kevin! If you have a lot of keys, I imagine it is easier to get the list from Google or msdn. Maybe make a label that updates every keydown so you can do them quicker than I demonstrated. :) thanks again
Very nice and useful input idea. Can this be put on a worksheet instead of a userform and into multiple cells - say down column "A" where a date needs to be entered for each record in cells A2, A3,A4 and so on and where A3 takes A2 default date. Also when you re-open the spreadsheet the next blank cell in column A takes today's default date. Your help is appreciated
Hi B Vora, probably so, do you have a sample or demo workbook you can send me so I know what you're thinking more specifically? www.Excelvbaisfun.com/contact Thanks Dan
This code is exactly what I was looking for. Thank you. I did run into a little problem though. The up, right and down arrows worked perfectly but the down arrow moved back 1 day and then the cursor jumped to the next control on the userform. I had to add a keycode=false after the if keycode = 40. Any ideas why this happens?
Hi Ola, I think the CDate function chooses this format for date conversion, but if you want the output to match yours, you can easily convert it to that format. me.tbDate = FORMAT( CDate(Me.tbDate) + 1, "yyyy-mm-dd" ) for example...
Thanks again Dan, That solved the issue. I was under the impression that the date format was set by the system locale and in my case(Swedish) it's supposed to be YYYY-MM-DD. If I did not use this formula, when saving from the user form back to the sheet it was converted to text and not a date at all. Oh well, as long as I know the work around it's good enough. :-)
sir this code is working perfectly fine. But i have problem sir, i add 3 more lable to show 'd', 'dd', 'ddd' and 'dddd' format all at once. what happens is focus (cursor) keeps toggling between all 4 labels other than tbdate button and increment or decrement does not happen. when focus is in tbdate only all increment and decrement works. can we fix focus to tbdate only. hope i have explained correctly.
Thanks for the fun with dates Daniel. Love the method of determining the keycode pressed.
Thanks krn14242, I didn't know people would like that method so much! Must be a Kevin thing. :)
Thanks of the quick tip!
Thank YOU, ExcelIsFun! You are da man! Everyone go watch Mike's amazing videos, right now!!
Yes, but not until they are watch all of your amazing videos : )
Thanks for this handy trick
So glad it was helpful, Syed Muzammil Mahasan Shahi!
Great Video! Keep it up.
Thanks, Binh Le!
Very cool tricks. I would have been busy googling to get the keyval codes, I will put your trick of getting the parameter value by hovering the mouse over it a ton!!!
Thanks, Kevin! If you have a lot of keys, I imagine it is easier to get the list from Google or msdn. Maybe make a label that updates every keydown so you can do them quicker than I demonstrated. :) thanks again
Excellent!
Thanks, Nicolas!
hi dear your work is great respects for that
i just wanted to know that can we get ddmmyyyy in this formula
Very nice and useful input idea. Can this be put on a worksheet instead of a userform and into multiple cells - say down column "A" where a date needs to be entered for each record in cells A2, A3,A4 and so on and where A3 takes A2 default date.
Also when you re-open the spreadsheet the next blank cell in column A takes today's default date. Your help is appreciated
Hi B Vora, probably so, do you have a sample or demo workbook you can send me so I know what you're thinking more specifically? www.Excelvbaisfun.com/contact
Thanks
Dan
Great Thanks
Very welcome, Emil!
Can we do it in worksheet with no userform. Like in particular cell through vba codes.
This code is exactly what I was looking for. Thank you. I did run into a little problem though. The up, right and down arrows worked perfectly but the down arrow moved back 1 day and then the cursor jumped to the next control on the userform. I had to add a keycode=false after the if keycode = 40. Any ideas why this happens?
Thanks Dan.
I used it and it works well. However the cdate is changing the date form I use from YYYY-MM-DD to M/D/YYYY.
Why is that?
Hi Ola,
I think the CDate function chooses this format for date conversion, but if you want the output to match yours, you can easily convert it to that format.
me.tbDate = FORMAT( CDate(Me.tbDate) + 1, "yyyy-mm-dd" )
for example...
Thanks again Dan,
That solved the issue.
I was under the impression that the date format was set by the system locale and in my case(Swedish) it's supposed to be YYYY-MM-DD.
If I did not use this formula, when saving from the user form back to the sheet it was converted to text and not a date at all.
Oh well, as long as I know the work around it's good enough. :-)
Great work, Ola!
How do I stop it from going to the next textbox on the userform when I press the arrow keys?
Hi Joel, I made a video to help you out: th-cam.com/video/yvb05dk8IjU/w-d-xo.html
Thanks
Dan
sir this code is working perfectly fine. But i have problem sir, i add 3 more lable to show 'd', 'dd', 'ddd' and 'dddd' format all at once. what happens is focus (cursor) keeps toggling between all 4 labels other than tbdate button and increment or decrement does not happen. when focus is in tbdate only all increment and decrement works. can we fix focus to tbdate only. hope i have explained correctly.