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.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
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 Lounger
-
-
WSHansV
AskWoody Lounger
Viewing 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
-
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
1 hour, 24 minutes ago -
False error message from eMClient
by
WSSebastian42
6 hours, 3 minutes ago -
Awoke to a rebooted Mac (crashed?)
by
rebop2020
4 hours, 19 minutes ago -
Office 2021 Perpetual for Mac
by
rebop2020
5 hours, 31 minutes ago -
AutoSave is for Microsoft, not for you
by
Will Fastie
8 minutes ago -
Difface : Reconstruction of 3D Human Facial Images from DNA Sequence
by
Alex5723
9 hours, 3 minutes ago -
Seven things we learned from WhatsApp vs. NSO Group spyware lawsuit
by
Alex5723
9 hours, 25 minutes ago -
Outdated Laptop
by
jdamkeene
14 hours, 29 minutes ago -
Updating Keepass2Android
by
CBFPD-Chief115
19 hours, 54 minutes ago -
Another big Microsoft layoff
by
Charlie
19 hours, 34 minutes ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
4 minutes ago -
May 2025 updates are out
by
Susan Bradley
10 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
1 day, 1 hour ago -
Windows 11 Insider Preview build 26120.3964 (24H2) released to BETA
by
joep517
1 day, 1 hour ago -
Drivers suggested via Windows Update
by
Tex265
1 day, 1 hour ago -
Thunderbird release notes for 128 esr have disappeared
by
EricB
23 hours, 14 minutes ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
1 day, 8 hours ago -
Apple releases 18.5
by
Susan Bradley
1 day, 2 hours ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
1 day, 9 hours ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
1 day, 10 hours ago -
Windows 7 ISO /Windows 10 ISO
by
ECWS
17 hours, 49 minutes ago -
No HP software folders
by
fpefpe
1 day, 18 hours ago -
Which antivirus apps and VPNs are the most secure in 2025?
by
B. Livingston
15 hours, 34 minutes ago -
Stay connected anywhere
by
Peter Deegan
1 day, 23 hours ago -
Copilot, under the table
by
Will Fastie
2 hours, 2 minutes ago -
The Windows experience
by
Will Fastie
2 days, 5 hours ago -
A tale of two operating systems
by
Susan Bradley
10 hours, 5 minutes ago -
Microsoft : Resolving Blue Screen errors in Windows
by
Alex5723
2 days, 11 hours ago -
Where’s the cache today?
by
Up2you2
3 days, 2 hours ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
2 days, 19 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.