LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Search dates differences

It does work for unlimited rows but not for columns. If I have dates till the
end of the sheet (column IV), it does not give the correct result.

I think there is a lot of confusion in this thread. I am starting a new
thread for this issue with a clear explaination.

Thanx
Maxi

"David" wrote:

Sub Macro2()
Range("AV2").Select
Do Until ActiveCell.Value = ""
ThisRow = ActiveCell.Row
V0 = ActiveCell.Value
V1 = ActiveCell.Offset(0, 1).Value
V2 = ActiveCell.Offset(0, 2).Value
V3 = ActiveCell.Offset(0, 3).Value
V4 = ActiveCell.Offset(0, 4).Value
V5 = ActiveCell.Offset(0, 5).Value
V6 = ActiveCell.Offset(0, 6).Value
Val1 = V1 - V0
Val2 = V2 - V1
Val3 = V3 - V2
Val4 = V4 - V3
Val5 = V5 - V4
Val6 = V6 - V5
SaveVal = Val1
If Val2 Val1 Then SaveVal = Val2
If Val3 SaveVal Then SaveVal = Val3
If Val4 SaveVal Then SaveVal = Val4
If Val5 SaveVal Then SaveVal = Val5
If Val6 SaveVal Then SaveVal = Val6
Range("AS" & ThisRow).Value = SaveVal
Range("AT" & ThisRow).Value = Val6
ActiveCell.Offset(1, 0).Select
Loop
End Sub
If the dates are elsewhere, then the relationships of the dates must be
spelled out. This will work for what you have shown.

"mac_see" wrote:

Dates can also be in more columns. Lets say AV2:IV1056

The code should work irrespective of the rows and columns.

Maxi

"mac_see" wrote:

It works but it will stop at BB10. if I have dates in more rows lets say
AV2:BB750, the code would be very long. I don't know VBA but can you use
something like xlDown so that irrespective of the date range, it will still
give you result and the code will be short?

 
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
adding differences between dates RobertK Excel Discussion (Misc queries) 6 September 18th 09 06:40 PM
Differences between Dates Jack Excel Worksheet Functions 5 July 7th 08 08:50 PM
Calculating time differences across two (or more) dates jonewer Excel Discussion (Misc queries) 1 May 11th 06 10:22 AM
Calculating differences in dates Paul Sheppard Excel Discussion (Misc queries) 5 June 30th 05 01:18 PM
Calculating differences between dates ALISONHELP Excel Worksheet Functions 2 April 6th 05 10:27 AM


All times are GMT +1. The time now is 10:53 AM.

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

About Us

"It's about Microsoft Excel"