Active X button

Romano_odK

Active Member
Joined
Jun 4, 2020
Messages
379
Office Version
  1. 365
Platform
  1. Windows
Good evening,

Would it be possible to make an active X button that would give me the todays date but needs to give it to me like yyyy-mm-dd. It needs to be this exactly and this is not common for my part of the world.

Thank you for your time.

Romano
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi Romano_odK,

You could try this...
VBA Code:
MsgBox Format(Date, "yyyy-mm-dd")

Hope that helps,

Doug
 
Upvote 0
Hi Romano_odK,

You could try this...
VBA Code:
MsgBox Format(Date, "yyyy-mm-dd")

Hope that helps,

Doug
I should haven been more clearly I seen now. I would like the date to be placed in cell B2. Is that possible?
 
Upvote 0
Macro:
VBA Code:
Sub Time()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    For Each Cell In ws.Range("B2").Cells
        Range("B2").Value = Date
    Next Cell
End Sub


Then set cell format to : Custom > yyyy-mm-dd


I guess it could also be this:
VBA Code:
Sub Time()

        Range("B2").Value = Date

End Sub
 
Upvote 0
Got it!

This will insert current date to B2, then make sure format is yyyy-mm-dd.

VBA Code:
Sub Time()

        Range("B2").Value = Date
        Range("B2").NumberFormat = "yyyy-mm-dd"

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,918
Members
449,195
Latest member
Stevenciu

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