ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What variable would I use to aquire Today() (https://www.excelbanter.com/excel-programming/340521-what-variable-would-i-use-aquire-today.html)

CRayF

What variable would I use to aquire Today()
 
I have this working except that I want 09/19/05 to equal Today()'s date
What would this line need to look like?
Range("Q4") = "09/19/05"

------------
If Target.Address = "$P$4" Then
If Range("Q4") = "mm/dd" Then
Range("Q4") = "09/19/05"
Range("C12").Select
Else
Range("Q4") = "mm/dd"
Range("Q4").Select
End If
End If
------------


Dave Peterson

What variable would I use to aquire Today()
 
With Range("Q4")
.value = date
.numberformat = "mm/dd/yy"
end with



CRayF wrote:

I have this working except that I want 09/19/05 to equal Today()'s date
What would this line need to look like?
Range("Q4") = "09/19/05"

------------
If Target.Address = "$P$4" Then
If Range("Q4") = "mm/dd" Then
Range("Q4") = "09/19/05"
Range("C12").Select
Else
Range("Q4") = "mm/dd"
Range("Q4").Select
End If
End If
------------


--

Dave Peterson

Ron Rosenfeld

What variable would I use to aquire Today()
 
On Mon, 19 Sep 2005 12:07:03 -0700, "CRayF"
wrote:

I have this working except that I want 09/19/05 to equal Today()'s date
What would this line need to look like?
Range("Q4") = "09/19/05"

------------
If Target.Address = "$P$4" Then
If Range("Q4") = "mm/dd" Then
Range("Q4") = "09/19/05"
Range("C12").Select
Else
Range("Q4") = "mm/dd"
Range("Q4").Select
End If
End If
------------


Probably you want to use the Date function:

Range("Q4") = Date


--ron

CRayF

What variable would I use to aquire Today()
 
Works like a champ... thanks

If Target.Address = "$P$4" Then
If Range("Q4") = "mm/dd" Then
With Range("Q4")
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
Range("C12").Select
Else
Range("Q4") = "mm/dd"
Range("Q4").Select
End If
End If


"Dave Peterson" wrote:

With Range("Q4")
.value = date
.numberformat = "mm/dd/yy"
end with



CRayF

What variable would I use to aquire Today()
 
Thanks... All works great...
This is what I ended up with...
P4 starts out as a value of "T" and Q4 equals "<- Click"
When P4 ("T"oday) is selected , it places todays date in Q4 and changes P4
to a "C" for "Clear". When selected again ("C") then it replaces todays date
with "<- Click". and P4 back to "T". This toggles back and forth when
selected.
---------------
If Target.Address = "$P$4" Then
If Range("Q4") = "<- Click" Then
With Range("Q4")
Range("Q4") = Date
Range("P4") = "C"
End With
Range("C12").Select
Else
Range("Q4") = "<- Click"
Range("P4") = "T"
Range("Q4").Select
End If
End If
---------------------------

"Ron Rosenfeld" wrote:

On Mon, 19 Sep 2005 12:07:03 -0700, "CRayF"
wrote:

I have this working except that I want 09/19/05 to equal Today()'s date
What would this line need to look like?
Range("Q4") = "09/19/05"

------------
If Target.Address = "$P$4" Then
If Range("Q4") = "mm/dd" Then
Range("Q4") = "09/19/05"
Range("C12").Select
Else
Range("Q4") = "mm/dd"
Range("Q4").Select
End If
End If
------------


Probably you want to use the Date function:

Range("Q4") = Date


--ron



All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com