Posted to microsoft.public.excel.programming
|
|
vba for Today()
Thank you joel,
I Learned new thing.I used Cells(j,"B")=Int(Now) ,it gave me desired results.
thank you once again.
"joel" wrote:
I see two problems with your posting
1) the dfgference between now() and today is now includes hours and minutes
while today(0 is set at midnight of the date. Time is a number with days the
whole part of the number and hours and minutes are the fractional part.
April, 7, 2009 = 39910. 8 AM is 8hours/24 hours = .3333333
So today() = 39910 and Now() = 39910.3333333333
Using the INT function will make them equivalent
Today() = Int(Now())
2) A text box returns TEXT not a Date. You need to use the
DATEVALUE("4/1/09") function to convert the text string to a number.
DateValue will take any format string the excel recognizes "4/1/09",
"4/1/2009", "April 1, 2009"). the only problem with datevalue is the
internation standards wherre US has month 1st and England uses Day 1st.
from:
If Cells(j,"A")=Me.TextBox1.Text
to:
If Cells(j,"A")=DateValue(Me.TextBox1.Text)
"tkraju via OfficeKB.com" wrote:
I have w/sheet cell B1= Now(),i.e date with time.
what vba code should I use whether B1=today's date or not.
I use :- If Cells(j,"A")=Me.TextBox1.Text And Cells(j,"B")=today
its not giving me desired results.
--
Message posted via http://www.officekb.com
|