Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default calculate date diff in a cell

Hi.
I have a spread sheet that contains in the first column a date time
formatted field, in a few columns over, I have a field that I would like to
automatically calculate the days between the current rows date field and the
previous rows date field and put the number of days different in the days
diff column. Can anyone help me with this...?
Thanks,
Brian Shafer


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default calculate date diff in a cell

Brian,

If I understand you correctly (and I probably don't)

in a1 you have a value: 2006/01/01
in a2 you have a value: 2006/01/03

in b2 for days difference: =A2-A1

Robin Hammond
www.enhanceddatasystems.com

"Brian Shafer" wrote in message
...
Hi.
I have a spread sheet that contains in the first column a date time
formatted field, in a few columns over, I have a field that I would like
to automatically calculate the days between the current rows date field
and the previous rows date field and put the number of days different in
the days diff column. Can anyone help me with this...?
Thanks,
Brian Shafer




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default calculate date diff in a cell

yes, you are right.. but I want it to happen automatically when I enter a
valid date in t b1 write the diff in b2

"Robin Hammond" wrote in message
...
Brian,

If I understand you correctly (and I probably don't)

in a1 you have a value: 2006/01/01
in a2 you have a value: 2006/01/03

in b2 for days difference: =A2-A1

Robin Hammond
www.enhanceddatasystems.com

"Brian Shafer" wrote in message
...
Hi.
I have a spread sheet that contains in the first column a date time
formatted field, in a few columns over, I have a field that I would like
to automatically calculate the days between the current rows date field
and the previous rows date field and put the number of days different in
the days diff column. Can anyone help me with this...?
Thanks,
Brian Shafer






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default calculate date diff in a cell

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Row = 1 And Target.Column 1 Then
With Target
.Offset(1, 0).Value = .Value - .Offset(0, -1).Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Brian Shafer" wrote in message
...
yes, you are right.. but I want it to happen automatically when I enter a
valid date in t b1 write the diff in b2

"Robin Hammond" wrote in message
...
Brian,

If I understand you correctly (and I probably don't)

in a1 you have a value: 2006/01/01
in a2 you have a value: 2006/01/03

in b2 for days difference: =A2-A1

Robin Hammond
www.enhanceddatasystems.com

"Brian Shafer" wrote in message
...
Hi.
I have a spread sheet that contains in the first column a date time
formatted field, in a few columns over, I have a field that I would

like
to automatically calculate the days between the current rows date field
and the previous rows date field and put the number of days different

in
the days diff column. Can anyone help me with this...?
Thanks,
Brian Shafer








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default calculate date diff in a cell

Awesome... Thanks

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Row = 1 And Target.Column 1 Then
With Target
.Offset(1, 0).Value = .Value - .Offset(0, -1).Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Brian Shafer" wrote in message
...
yes, you are right.. but I want it to happen automatically when I enter a
valid date in t b1 write the diff in b2

"Robin Hammond" wrote in message
...
Brian,

If I understand you correctly (and I probably don't)

in a1 you have a value: 2006/01/01
in a2 you have a value: 2006/01/03

in b2 for days difference: =A2-A1

Robin Hammond
www.enhanceddatasystems.com

"Brian Shafer" wrote in message
...
Hi.
I have a spread sheet that contains in the first column a date time
formatted field, in a few columns over, I have a field that I would

like
to automatically calculate the days between the current rows date field
and the previous rows date field and put the number of days different

in
the days diff column. Can anyone help me with this...?
Thanks,
Brian Shafer









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
Calculate diff. between 2 times Connie Martin Excel Worksheet Functions 3 March 20th 09 05:05 PM
aps3 calculate diff in time and cinvert into another format abe Excel Worksheet Functions 1 April 26th 06 08:55 PM
formula to calculate future date from date in cell plus days Chicesq Excel Worksheet Functions 8 November 3rd 05 12:25 PM
Calculate month-end date from date in adjacent cell? Matt D Francis Excel Worksheet Functions 4 May 19th 05 04:55 AM


All times are GMT +1. The time now is 01:14 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"