Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba for Today()
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba for Today()
Use Date()
If Cells(j,"A")=Me.TextBox1.Text And Cells(j,"B")= Date() If this post helps click Yes --------------- Jacob Skaria "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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba for Today()
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba for Today()
If Format(Range("A1"),"dd-mm-yyyy")=format(Date(),"dd-mm-yyyy")
If this post helps click Yes --------------- Jacob Skaria "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 |
#5
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba for Today()
Thank you Joel,
I learned a new thing,I used Cells(j,"B")=Int(Now) ,it gave me desired results. Thanks 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) 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 OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200904/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
today | Excel Discussion (Misc queries) | |||
Keep 6 months of dates from Today to (Today + 6 Months) | Excel Programming | |||
Before today | Excel Discussion (Misc queries) | |||
IF TODAY equals date in cell A10, or if TODAY is beyond that date | Excel Worksheet Functions | |||
=IF(OR(TODAY() |
Excel Discussion (Misc queries) |