Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Checking difference between the dates

I have uploaded my workeet at the following link
http://www25.brinkster.com/shreejipc...Difference.htm


What I want to do is, check the difference between the two dates AW2-AV2 and
keep it in memory, then check difference of AX2-AW2, keep it in memory... do
this till the last date in the same row and whichever number is highest in
the memory, put in it cell AS2. Continue the same thing till the last row.

Note: there is no fixed row or column for the dates, the dates can go up to
the last column IV and the last row 65536.

I have a date in cell B1 (which is a dynamic date and I will keep on
changing the date as per my requirements). I want to check the difference
between the date in cell B1 and the last date in the first row and put it in
cell AT2. Then check the difference between the date in cell B1 and the last
date in the second row and put it in cell AT2... do this till the last row.

Maxi
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Checking difference between the dates

Try this:

Sub DateDifferences()

Dim v(256) As Variant
Dim iLastRow As Long, iLastCol As Integer
Dim r As Long, c As Integer, i As Integer

iLastRow = Cells(Rows.Count, "AV").End(xlUp).Row

For r = 2 To iLastRow

iLastCol = Cells(r, Columns.Count).End(xlToLeft).Column ' Find Last Column

i = 0
For c = Cells(r, "AW").Column To iLastCol ' Calculate Date Differences
v(i) = Cells(r, c).Value - Cells(r, c - 1).Value
i = i + 1
Next c

Cells(r, "AS") = Application.Max(v) ' Get Maximum
Cells(r, "AT") = Cells(r, iLastCol) - Range("B1") ' Last Date - B1

Next r

End Sub


"mac_see" wrote:

I have uploaded my workeet at the following link
http://www25.brinkster.com/shreejipc...Difference.htm


What I want to do is, check the difference between the two dates AW2-AV2 and
keep it in memory, then check difference of AX2-AW2, keep it in memory... do
this till the last date in the same row and whichever number is highest in
the memory, put in it cell AS2. Continue the same thing till the last row.

Note: there is no fixed row or column for the dates, the dates can go up to
the last column IV and the last row 65536.

I have a date in cell B1 (which is a dynamic date and I will keep on
changing the date as per my requirements). I want to check the difference
between the date in cell B1 and the last date in the first row and put it in
cell AT2. Then check the difference between the date in cell B1 and the last
date in the second row and put it in cell AT2... do this till the last row.

Maxi

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Checking difference between the dates

That worked !!! Thank you so much !

"Toppers" wrote:

Try this:

Sub DateDifferences()

Dim v(256) As Variant
Dim iLastRow As Long, iLastCol As Integer
Dim r As Long, c As Integer, i As Integer

iLastRow = Cells(Rows.Count, "AV").End(xlUp).Row

For r = 2 To iLastRow

iLastCol = Cells(r, Columns.Count).End(xlToLeft).Column ' Find Last Column

i = 0
For c = Cells(r, "AW").Column To iLastCol ' Calculate Date Differences
v(i) = Cells(r, c).Value - Cells(r, c - 1).Value
i = i + 1
Next c

Cells(r, "AS") = Application.Max(v) ' Get Maximum
Cells(r, "AT") = Cells(r, iLastCol) - Range("B1") ' Last Date - B1

Next r

End Sub


"mac_see" wrote:

I have uploaded my workeet at the following link
http://www25.brinkster.com/shreejipc...Difference.htm


What I want to do is, check the difference between the two dates AW2-AV2 and
keep it in memory, then check difference of AX2-AW2, keep it in memory... do
this till the last date in the same row and whichever number is highest in
the memory, put in it cell AS2. Continue the same thing till the last row.

Note: there is no fixed row or column for the dates, the dates can go up to
the last column IV and the last row 65536.

I have a date in cell B1 (which is a dynamic date and I will keep on
changing the date as per my requirements). I want to check the difference
between the date in cell B1 and the last date in the first row and put it in
cell AT2. Then check the difference between the date in cell B1 and the last
date in the second row and put it in cell AT2... do this till the last row.

Maxi

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
Checking Dates against Bank Holidays Gary T Excel Worksheet Functions 2 November 19th 07 03:03 PM
Sumproduct checking between two dates bikergsx Excel Worksheet Functions 2 May 26th 06 10:21 AM
Checking previous 7 rows for dates and values Mark[_50_] Excel Programming 1 November 26th 04 09:17 PM
Checking for invalid dates Matt Pinto Excel Programming 3 November 28th 03 12:11 PM
Checking Military Dates Otto Moehrbach[_3_] Excel Programming 14 July 13th 03 05:24 PM


All times are GMT +1. The time now is 09:16 PM.

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"