I have an excel file with a date column. I want to be able to sort the work sheet by that column and then run though the column and list all the gaps in the dates between consecutive records. For instance if cell C1 = 11/12/03 and C2 = 11/17/03 then the result would be 11/13/03 – 11/16/03. If C3=11/17/18 or 11/18/03 then the result would be No Gap. Not sure that this is possible?
Thanks.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Date Gap analysis (Excel 2000)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Date Gap analysis (Excel 2000)
- This topic has 32 replies, 6 voices, and was last updated 21 years, 6 months ago.
AuthorTopicWSwannaknow
AskWoody LoungerNovember 4, 2003 at 9:36 pm #396082Viewing 3 reply threadsAuthorReplies-
WSAlexya1
AskWoody LoungerNovember 4, 2003 at 10:08 pm #739546 -
WSAlexya1
AskWoody LoungerNovember 4, 2003 at 10:08 pm #739547 -
WSHansV
AskWoody Lounger -
WSAlexya1
AskWoody Lounger -
WSHansV
AskWoody Lounger -
WSAlexya1
AskWoody Lounger -
WSHansV
AskWoody Lounger -
WSwannaknow
AskWoody LoungerNovember 5, 2003 at 4:52 pm #739954Thanks to both of you for sharing the knowledge.
Is there is way to turn this into a macro/script that would automatically run for a selected column?
For example, if the dates are in column C, it would automatically populate column D with this formula for every record in C that had an entry?Thanks!
-
WSsdckapr
AskWoody LoungerNovember 6, 2003 at 11:49 am #739973(Edited by sdckapr on 06-Nov-03 07:49. Corrected “brain-fart”. Thanks, Tony.)
Don’t understand the need for a macro.
Why not (after you sort the data) put the formula in the top cell. Then select the cell and move the mouse to the bottom right corner of the cell (the cursor will change from a fat plus to a narrow plus. When it is the narrow plus dbl-click and the formula will be copied down the rows to the bottom of the data set.Steve
-
WSwannaknow
AskWoody Lounger -
WSsdckapr
AskWoody LoungerNovember 5, 2003 at 6:04 pm #739991Does the macro need to check for blanks within the data set or should you just fill in the formula from D2 to the last filled cell in C?
Do you want to keep the formulas in it or do you want the macro to just put the result of the formula?What all do you want to automate?
Should the macro work with just one sheet, all sheets in the activeworkbook, selected sheets in the activeworkbook, sheets with particular names in all open workbooks?You could do alot of it yourself, using the macro recorder and then generalize it.
Steve
-
WSwannaknow
AskWoody LoungerNovember 5, 2003 at 6:23 pm #740001Thanks Steve, I did attempt to use the macro recorder but was not sure how to generalize the column location, or the auto-fill to match the amount of records in the work sheet as that will vary…..
First i would like the macro to sort the entire sheet by the date column, C. (If it is not always C, can this be a parameter, or will i need to set this in the macro?) For a given date column, C, fill in the value in column D for every record in column C.
Macreo should only do the active sheet.Thanks.
-
H. Legare Coleman
AskWoody PlusNovember 6, 2003 at 1:57 am #740341The macro below will insert a column to the right of the column containing the active cell, and will then put Hans’ formula into rows 2 through the last row containing data in the column containing the active cell.
Option Explicit Public Sub AddFormula() Dim I As Long, lLastRow As Long, lCol As Long Dim oCell As Range lCol = Selection.Column Set oCell = ActiveSheet.Cells(1, lCol) lLastRow = ActiveSheet.Cells(65536, lCol).End(xlUp).Row - 1 oCell.Offset(0, 1).EntireColumn.Insert For I = 1 To lLastRow oCell.Offset(I, 1).FormulaR1C1 = _ "=IF(RC[-1]-R[-1]C[-1]=1,""No Gap"",TEXT(R[-1]C[-1],""mm/dd/yy"")&"" - ""&TEXT(RC[-1],""mm/dd/yy""))" Next I oCell.Offset(0, 1).EntireColumn.AutoFit End Sub
-
WSwannaknow
AskWoody Lounger -
WSwannaknow
AskWoody Lounger -
H. Legare Coleman
AskWoody PlusNovember 6, 2003 at 1:57 am #740342The macro below will insert a column to the right of the column containing the active cell, and will then put Hans’ formula into rows 2 through the last row containing data in the column containing the active cell.
Option Explicit Public Sub AddFormula() Dim I As Long, lLastRow As Long, lCol As Long Dim oCell As Range lCol = Selection.Column Set oCell = ActiveSheet.Cells(1, lCol) lLastRow = ActiveSheet.Cells(65536, lCol).End(xlUp).Row - 1 oCell.Offset(0, 1).EntireColumn.Insert For I = 1 To lLastRow oCell.Offset(I, 1).FormulaR1C1 = _ "=IF(RC[-1]-R[-1]C[-1]=1,""No Gap"",TEXT(R[-1]C[-1],""mm/dd/yy"")&"" - ""&TEXT(RC[-1],""mm/dd/yy""))" Next I oCell.Offset(0, 1).EntireColumn.AutoFit End Sub
-
WSwannaknow
AskWoody LoungerNovember 5, 2003 at 6:23 pm #740002Thanks Steve, I did attempt to use the macro recorder but was not sure how to generalize the column location, or the auto-fill to match the amount of records in the work sheet as that will vary…..
First i would like the macro to sort the entire sheet by the date column, C. (If it is not always C, can this be a parameter, or will i need to set this in the macro?) For a given date column, C, fill in the value in column D for every record in column C.
Macreo should only do the active sheet.Thanks.
-
WSsdckapr
AskWoody LoungerNovember 5, 2003 at 6:04 pm #739992Does the macro need to check for blanks within the data set or should you just fill in the formula from D2 to the last filled cell in C?
Do you want to keep the formulas in it or do you want the macro to just put the result of the formula?What all do you want to automate?
Should the macro work with just one sheet, all sheets in the activeworkbook, selected sheets in the activeworkbook, sheets with particular names in all open workbooks?You could do alot of it yourself, using the macro recorder and then generalize it.
Steve
-
WSwannaknow
AskWoody Lounger -
WSBilasTasol
AskWoody LoungerNovember 6, 2003 at 11:46 am #740455 -
WSsdckapr
AskWoody Lounger -
WSsdckapr
AskWoody Lounger -
WSBilasTasol
AskWoody Lounger -
WSBilasTasol
AskWoody Lounger -
WSBilasTasol
AskWoody LoungerNovember 6, 2003 at 11:46 am #740456 -
WSsdckapr
AskWoody LoungerNovember 6, 2003 at 11:49 am #739974(Edited by sdckapr on 06-Nov-03 07:49. Corrected “brain-fart”. Thanks, Tony.)
Don’t understand the need for a macro.
Why not (after you sort the data) put the formula in the top cell. Then select the cell and move the mouse to the bottom right corner of the cell (the cursor will change from a fat plus to a narrow plus. When it is the narrow plus dbl-click and the formula will be copied down the rows to the bottom of the data set.Steve
-
WSwannaknow
AskWoody LoungerNovember 5, 2003 at 4:52 pm #739955Thanks to both of you for sharing the knowledge.
Is there is way to turn this into a macro/script that would automatically run for a selected column?
For example, if the dates are in column C, it would automatically populate column D with this formula for every record in C that had an entry?Thanks!
-
WSHansV
AskWoody Lounger
-
-
-
WSAlexya1
AskWoody Lounger
-
-
-
WSHansV
AskWoody Lounger
WSAlexya1
AskWoody LoungerWSHansV
AskWoody LoungerViewing 3 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
1 hour, 23 minutes ago -
Windows Update orchestration platform to update all software
by
Alex5723
5 hours, 56 minutes ago -
May preview updates
by
Susan Bradley
7 hours, 34 minutes ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
7 hours, 41 minutes ago -
Just got this pop-up page while browsing
by
Alex5723
5 hours, 37 minutes ago -
KB5058379 / KB 5061768 Failures
by
crown
2 hours, 33 minutes ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
6 minutes ago -
At last – installation of 24H2
by
Botswana12
21 hours, 28 minutes ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
2 hours, 19 minutes ago -
RyTuneX optimize Windows 10/11 tool
by
Alex5723
1 day, 9 hours ago -
Can I just update from Win11 22H2 to 23H2?
by
Dave Easley
1 day, 2 hours ago -
Limited account permission error related to Windows Update
by
gtd12345
1 day, 23 hours ago -
Another test post
by
gtd12345
1 day, 23 hours ago -
Connect to someone else computer
by
wadeer
1 day, 17 hours ago -
Limit on User names?
by
CWBillow
1 day, 20 hours ago -
Choose the right apps for traveling
by
Peter Deegan
1 day, 10 hours ago -
BitLocker rears its head
by
Susan Bradley
18 hours, 40 minutes ago -
Who are you? (2025 edition)
by
Will Fastie
17 hours, 37 minutes ago -
AskWoody at the computer museum, round two
by
Will Fastie
1 day, 13 hours ago -
A smarter, simpler Firefox address bar
by
Alex5723
2 days, 9 hours ago -
Woody
by
Scott
2 days, 18 hours ago -
24H2 has suppressed my favoured spider
by
Davidhs
18 hours, 17 minutes ago -
GeForce RTX 5060 in certain motherboards could experience blank screens
by
Alex5723
3 days, 9 hours ago -
MS Office 365 Home on MAC
by
MickIver
3 days, 2 hours ago -
Google’s Veo3 video generator. Before you ask: yes, everything is AI here
by
Alex5723
3 days, 23 hours ago -
Flash Drive Eject Error for Still In Use
by
J9438
18 hours, 2 minutes ago -
Windows 11 Insider Preview build 27863 released to Canary
by
joep517
4 days, 18 hours ago -
Windows 11 Insider Preview build 26120.4161 (24H2) released to BETA
by
joep517
4 days, 18 hours ago -
AI model turns to blackmail when engineers try to take it offline
by
Cybertooth
3 days, 21 hours ago -
Migrate off MS365 to Apple Products
by
dmt_3904
3 days, 22 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.