A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Discussion (Misc queries)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

to find number of days between 2 dates using vba code in excel



 
 
Thread Tools Display Modes
  #1  
Old November 3rd 05, 03:54 AM
sjayar
external usenet poster
 
Posts: n/a
Default to find number of days between 2 dates using vba code in excel


Hi All,

i have 2 DateTime Pickers and a textbox.
This texbox should contain the number of days between these 2 dates.

I am unable to calculate number of days between 2 dates.

I have used DateDIf function in the VBA code

when i run the program i get "Compile error: Sub or Function not
defined"

*Please help me to solve this problem.
1. why i get this "Sub or function not defined error"
2. What to do to solve these kind of problem
3. Please help to calculate the number of days between given 2 dates*


--
sjayar
------------------------------------------------------------------------
sjayar's Profile: http://www.excelforum.com/member.php...o&userid=28435
View this thread: http://www.excelforum.com/showthread...hreadid=481758

Ads
  #2  
Old November 3rd 05, 05:18 AM
Rowan Drummond
external usenet poster
 
Posts: n/a
Default to find number of days between 2 dates using vba code in excel

If you want the number of days between two dates just subtract one from
the other:

Private Sub DTPicker2_Change()
Dim sDate As Date
Dim eDate As Date
sDate = Me.DTPicker1.Value
eDate = Me.DTPicker2.Value
Me.TextBox1 = eDate - sDate
End Sub

Hope this helps
Rowan

sjayar wrote:
> Hi All,
>
> i have 2 DateTime Pickers and a textbox.
> This texbox should contain the number of days between these 2 dates.
>
> I am unable to calculate number of days between 2 dates.
>
> I have used DateDIf function in the VBA code
>
> when i run the program i get "Compile error: Sub or Function not
> defined"
>
> *Please help me to solve this problem.
> 1. why i get this "Sub or function not defined error"
> 2. What to do to solve these kind of problem
> 3. Please help to calculate the number of days between given 2 dates*
>
>

  #3  
Old November 3rd 05, 06:18 AM
sjayar
external usenet poster
 
Posts: n/a
Default to find number of days between 2 dates using vba code in excel


hi ,
thanks rowan for ur help.
ur suggestion worked


--
sjayar
------------------------------------------------------------------------
sjayar's Profile: http://www.excelforum.com/member.php...o&userid=28435
View this thread: http://www.excelforum.com/showthread...hreadid=481758

  #4  
Old November 3rd 05, 06:24 AM
Rowan Drummond
external usenet poster
 
Posts: n/a
Default to find number of days between 2 dates using vba code in excel

You're welcome.

sjayar wrote:
> hi ,
> thanks rowan for ur help.
> ur suggestion worked
>
>

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I get Excel to find the first number in a list greater tha krowlan Excel Worksheet Functions 3 October 27th 05 06:15 PM
Number of years, months, days between two dates. Bluenose Excel Worksheet Functions 34 June 30th 05 02:18 PM
Calculate number of days in a column of dates Barbara Excel Discussion (Misc queries) 8 May 25th 05 02:48 PM
Where is DateDiff function in Excel 2002 ? Nigel Welch Excel Worksheet Functions 4 March 4th 05 03:18 PM
Using the Find tool in EXCEL TK Excel Worksheet Functions 2 February 11th 05 07:51 PM


All times are GMT +1. The time now is 09:43 AM.


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