Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
today stew Excel Discussion (Misc queries) 4 September 19th 08 06:15 PM
Keep 6 months of dates from Today to (Today + 6 Months) Joe K. Excel Programming 1 October 9th 07 07:02 PM
Before today MAustin Excel Discussion (Misc queries) 2 October 2nd 07 04:54 PM
IF TODAY equals date in cell A10, or if TODAY is beyond that date SoupNazi Excel Worksheet Functions 4 April 23rd 07 01:14 AM
=IF(OR(TODAY()G9),"Pass","Overdue") Why doe it not wo. Fkor Excel Discussion (Misc queries) 3 March 10th 05 08:29 AM


All times are GMT +1. The time now is 07:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"