{"id":81,"date":"2019-04-08T18:06:17","date_gmt":"2019-04-08T18:06:17","guid":{"rendered":"https:\/\/keithratner.live\/optionexplicit\/?p=81"},"modified":"2019-04-26T21:03:12","modified_gmt":"2019-04-26T21:03:12","slug":"elapsedtime","status":"publish","type":"post","link":"https:\/\/keithratner.live\/optionexplicit\/elapsedtime\/","title":{"rendered":"ElapsedTime"},"content":{"rendered":"<pre>Function ElapsedTime( _\r\n    endTime As Date, _\r\n    startTime As Date _\r\n) As String\r\n    Dim Interval As Date\r\n    ' Calculate the time interval.\r\n    Interval = endTime - startTime\r\n    ' Format and print the time interval in \r\n    ' days, hours, minutes and seconds.\r\n    ElapsedTime = _\r\n        Int( _\r\n            CSng( _\r\n                Interval _\r\n            ) _\r\n        ) &amp; _\r\n        \" days \" &amp; _\r\n        Format( _\r\n            Interval, _\r\n            \"hh\" _\r\n        ) &amp; _\r\n        \" Hours \" &amp; _\r\n        Format( _\r\n            Interval, _\r\n            \"nn\" _\r\n        ) &amp; _\r\n        \" Minutes \" &amp; _\r\n        Format( _\r\n            Interval, _\r\n            \"ss\" _\r\n        ) &amp; _\r\n        \" Seconds\"\r\nEnd Function<\/pre>\n<p>This has been adapted from <a href=\"https:\/\/docs.microsoft.com\/en-us\/office\/vba\/access\/concepts\/date-time\/calculate-elapsed-time\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.microsoft.com\/en-us\/office\/vba\/access\/concepts\/date-time\/calculate-elapsed-time<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Function ElapsedTime( _ endTime As Date, _ startTime As Date _ ) As String Dim Interval As Date &#8216; Calculate the time interval. Interval = endTime &#8211; startTime &#8216; Format and print the time interval in &#8216; days, hours, minutes and seconds. ElapsedTime = _ Int( _ CSng( _ Interval _ ) _ ) &amp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":107,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[114],"tags":[163],"class_list":["post-81","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippet","tag-performance"],"krwpengineoptions-featuredonwpengineblog":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgsIIA-1j","jetpack-related-posts":[{"id":35,"url":"https:\/\/keithratner.live\/optionexplicit\/export-modules-to-folder\/","url_meta":{"origin":81,"position":0},"title":"Export Modules to Folder","author":"Keith","date":"April 3, 2019","format":false,"excerpt":"This will create a folder using the base name of your Excel file, which is the filename without its extension, along with a vba subfolder. Your VBA modules will be placed there. Pass UseTimestamp:=True to put each export in its own timestamped subfolder so repeated runs don't overwrite earlier exports.\u2026","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"Export Modules","src":"https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/4-4-2019-2-16-36-AM.png?fit=665%2C496&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/4-4-2019-2-16-36-AM.png?fit=665%2C496&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/4-4-2019-2-16-36-AM.png?fit=665%2C496&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":83,"url":"https:\/\/keithratner.live\/optionexplicit\/haskey\/","url_meta":{"origin":81,"position":1},"title":"HasKey","author":"Keith","date":"April 8, 2019","format":false,"excerpt":"Function HasKey( _ coll As Collection, _ index As Variant _ ) As Boolean On Error GoTo ErrorHandler Dim elTest As Variant HasKey = False elTest = coll(index) HasKey = True Exit Function ErrorHandler: End Function","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":186,"url":"https:\/\/keithratner.live\/optionexplicit\/getlastusedrownumberinworksheet\/","url_meta":{"origin":81,"position":2},"title":"GetLastUsedRowNumberInWorksheet","author":"Keith","date":"August 14, 2019","format":false,"excerpt":"Function GetLastUsedRowNumberInWorksheet( _ ws As Worksheet _ ) As Long Dim _ rng As Range, _ rngResults As Range Set rng = _ ws.Cells Set rngResults = _ rng.Find( _ what:=\"*\", _ After:=rng.Cells(1), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False _ ) If _ rngResults Is Nothing\u2026","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":188,"url":"https:\/\/keithratner.live\/optionexplicit\/getlastusedcolumnnumberinworksheet\/","url_meta":{"origin":81,"position":3},"title":"GetLastUsedColumnNumberInWorksheet","author":"Keith","date":"August 14, 2019","format":false,"excerpt":"Function GetLastUsedColumnNumberInWorksheet( _ ws As Worksheet _ ) As Long Dim _ rng As Range, _ rngResults As Range Set rng = _ ws.Cells Set rngResults = _ rng.Find( _ what:=\"*\", _ After:=rng.Cells(1), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, _ MatchCase:=False _ ) If _ rngResults Is Nothing\u2026","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":116,"url":"https:\/\/keithratner.live\/optionexplicit\/matchespattern\/","url_meta":{"origin":81,"position":4},"title":"MatchesPattern","author":"Keith","date":"April 10, 2019","format":false,"excerpt":"Public Function MatchesPattern( _ strInputTest As String, _ strInputPattern As String, _ Optional IgnoreCase As Boolean = True, _ Optional IsGlobal As Boolean = True _ ) As Boolean On Error GoTo Catch Dim objRegExp As New RegExp Set objRegExp = Nothing objRegExp.IgnoreCase = IgnoreCase objRegExp.Global = IsGlobal objRegExp.Pattern =\u2026","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/matchespattern.png?fit=318%2C299&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":609,"url":"https:\/\/keithratner.live\/optionexplicit\/iscellhighlighted\/","url_meta":{"origin":81,"position":5},"title":"IsCellHighlighted","author":"Keith","date":"May 24, 2024","format":false,"excerpt":"Function IsCellHighlighted(cell As Range) As Boolean IsCellHighlighted = (cell.Interior.ColorIndex <> xlNone)End Function","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/elapsedtime.png?fit=309%2C480&ssl=1","_links":{"self":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/comments?post=81"}],"version-history":[{"count":3,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":109,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts\/81\/revisions\/109"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/media\/107"}],"wp:attachment":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/media?parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/categories?post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/tags?post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}