VBA to Refresh cell back to certain date and time

DemonX

New Member
Joined
Jan 17, 2021
Messages
20
Office Version
  1. 2019
Platform
  1. Windows
I have made the following formula to calculate the time difference

1620572175602.png


using the following formula ;

=INT(B2-A2)&" Days "&HOUR(MOD(B2-A2,1))&" Hour "&MINUTE(MOD(B2-A2,1))&"minutes"

1620572200990.png


It would be great if anyone of you could help me with VBA to add into a button so I could reset values in Cell A2 and Cell B2 ( if need, to add more cells too ) back to default date and time value such as "01/01/2021 00:00"

Further, in the above formula, if I want to change the calculate structure from Month-Date-Year to Date-Month-Year , what are the changes I should do to =INT(B2-A2)&" Days "&HOUR(MOD(B2-A2,1))&" Hour "&MINUTE(MOD(B2-A2,1))&"minutes" ?

Appreciate any of kind assistance.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,223,631
Messages
6,173,465
Members
452,516
Latest member
archcalx

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