VBA code to auto-convert date

7abib0

New Member
Joined
Dec 4, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am a beginner in Excel and I appreciate your support in helping me with the below.

I need VBA code to auto-convert numbers entered in Cell F6, F7, and F27 to a Date format D-MMM-YY.

Example:
051223 to auto-convert to 5-Dec-23 without the need to run ALT+F8 or anything.

Appreciate to provide me with the full code as I am a beginner in Excel VBA.

Thank you in advance.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Are you sure you want a VBA solution? If the format of your date number is always 6 digits, no spaces where the date format is DDMMYY, you can do it with a formula and skip vba
tmp.xlsm
ABC
10512235-Dec-23
2
3
4
5
Sheet4
Cell Formulas
RangeFormula
B1B1=DATE("20" & RIGHT(A1,2),MID(A1,3,2),LEFT(A1,2))
 
Upvote 0
Thank you for your reply.

I want VBA code because I am using it in my daily work and my team needs to change the date frequently. So inserting the date as the number will save much time.

Screenshot 2023-12-05 223914.jpg


Also, I am using a Clear button which will clear any formula inserted in the same fields.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top