Setting Current Date via a button

DrakeFS

New Member
Joined
Sep 27, 2011
Messages
3
I am Using an If statement to check if something has been verfied in the last 30 days.

Code:
=IF(TODAY()<=DATE(2011, 9,27)+30,"Yes","No")

Now I would like to create a button that modifies the Date(y,m,d) field to current date. Anyone have a clue how I could set the y, m, and d to the current values using a button in excel?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
The resulting formula would make no sense then.

TODAY will always be less than TODAY + 30.

What are you trying to do?
 
Upvote 0
it actually works, if date was set to 2011, 8,27 it out puts no (which was 30 days away) The only thing it does is check to see if the date (which is static right now) is is greater than 30 days past.

The button should change to static date to the current date (still a static value) and allow me to click it to set the answer to yes every 30 days


I am not trying to set the Date() to Today() in the formula, I am trying to set the vaule of Date() to the current Date (it should remain static in the formula)

a VBA script is what I assume I will need to do this.
 
Last edited:
Upvote 0
I used cell A1, change as necessary:

Code:
Private Sub CommandButton1_Click()
Dim yr As Long, mh As Long, dy As Long, t As Long
t = Date
yr = Year(t): mh = Month(t): dy = Day(t)
Range("A1").Formula = "=IF(TODAY()<=DATE(" & yr & "," & mh & "," & dy & ")+30,""Yes"",""No"")"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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