{"id":612,"date":"2024-05-24T01:45:09","date_gmt":"2024-05-24T01:45:09","guid":{"rendered":"https:\/\/keithratner.live\/optionexplicit\/?p=612"},"modified":"2024-05-24T01:45:12","modified_gmt":"2024-05-24T01:45:12","slug":"compresspageranges","status":"publish","type":"post","link":"https:\/\/keithratner.live\/optionexplicit\/compresspageranges\/","title":{"rendered":"CompressPageRanges"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">Function CompressPageRanges(ByVal pageList As String) As String<br>    Dim pages() As String<br>    Dim i As Long<br>    Dim result As String<br>    Dim startPage As Long<br>    Dim endPage As Long<br>    <br>    pages = Split(pageList, \",\")<br>    <br>    For i = 0 To UBound(pages)<br>        If startPage = 0 Then<br>            startPage = CLng(pages(i))<br>            endPage = startPage<br>        ElseIf CLng(pages(i)) = endPage + 1 Then<br>            endPage = CLng(pages(i))<br>        Else<br>            If result &lt;> \"\" Then result = result &amp; \",\"<br>            If startPage = endPage Then<br>                result = result &amp; CStr(startPage)<br>            Else<br>                result = result &amp; CStr(startPage) &amp; \"-\" &amp; CStr(endPage)<br>            End If<br>            startPage = CLng(pages(i))<br>            endPage = startPage<br>        End If<br>    Next i<br>    <br>    If result &lt;> \"\" Then result = result &amp; \",\"<br>    If startPage = endPage Then<br>        result = result &amp; CStr(startPage)<br>    Else<br>        result = result &amp; CStr(startPage) &amp; \"-\" &amp; CStr(endPage)<br>    End If<br>    <br>    CompressPageRanges = result<br>End Function<br><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Function CompressPageRanges(ByVal pageList As String) As String Dim pages() As String Dim i As Long Dim result As String Dim startPage As Long Dim endPage As Long pages = Split(pageList, &#8220;,&#8221;) For i = 0 To UBound(pages) If startPage = 0 Then startPage = CLng(pages(i)) endPage = startPage ElseIf CLng(pages(i)) = endPage + 1 Then [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_exactmetrics_skip_tracking":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[114],"tags":[121,171],"class_list":["post-612","post","type-post","status-publish","format-standard","hentry","category-snippet","tag-excel","tag-workbook"],"krwpengineoptions-featuredonwpengineblog":"","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgsIIA-9S","jetpack-related-posts":[{"id":35,"url":"https:\/\/keithratner.live\/optionexplicit\/export-modules-to-folder\/","url_meta":{"origin":612,"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":72,"url":"https:\/\/keithratner.live\/optionexplicit\/renderlistcontrolheadings\/","url_meta":{"origin":612,"position":1},"title":"RenderListControlHeadings","author":"Keith","date":"April 7, 2019","format":false,"excerpt":"Public Sub RenderListControlHeadings( _ ListControl As Control, _ ColumnHeadingString As String, _ Optional FontWeight As Long = 400, _ Optional OffsetLeft As Long = 8 _ ) Dim ctls As Controls Dim iCtl As Control Dim strControlNameStub As String Dim strLabelNameStub As String Set ctls = ListControl.Parent.Controls strLabelNameStub = \"lbheading_\"\u2026","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"RenderListControlHeadings","src":"https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/renderlistcontrolheadings.png?fit=576%2C1008&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/renderlistcontrolheadings.png?fit=576%2C1008&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/renderlistcontrolheadings.png?fit=576%2C1008&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":155,"url":"https:\/\/keithratner.live\/optionexplicit\/getfilenamefromfullpath\/","url_meta":{"origin":612,"position":2},"title":"GetFileNameFromFullPath","author":"Keith","date":"May 6, 2019","format":false,"excerpt":"Public Function GetFileNameFromFullPath( _ sFullFileNameWithPath As String _ ) as String Dim fs As Object Set fs = CreateObject(\"Scripting.FileSystemObject\") GetFileNameFromFullPath = _ fs.GetFilename( _ sFullFileNameWithPath _ ) Set fs = Nothing 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":179,"url":"https:\/\/keithratner.live\/optionexplicit\/getfileextension\/","url_meta":{"origin":612,"position":3},"title":"GetFileExtension","author":"Keith","date":"August 12, 2019","format":false,"excerpt":"Public Function GetFileExtension( _ sFullFileNameWithPath As String _ ) As String Dim fs As Object Set fs = CreateObject(\"Scripting.FileSystemObject\") GetFileExtension = _ fs.GetExtensionName( _ sFullFileNameWithPath _ ) Set fs = Nothing 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":169,"url":"https:\/\/keithratner.live\/optionexplicit\/getfilepath\/","url_meta":{"origin":612,"position":4},"title":"GetFilePath","author":"Keith","date":"June 5, 2019","format":false,"excerpt":"Public Function GetFilePath( _ sFullFileNameWithPath As String _ ) As String Dim fs As Object Set fs = CreateObject(\"Scripting.FileSystemObject\") GetFilePath = _ fs.GetAbsolutePathName( _ sFullFileNameWithPath _ ) 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":150,"url":"https:\/\/keithratner.live\/optionexplicit\/getbasename\/","url_meta":{"origin":612,"position":5},"title":"GetBaseName","author":"Keith","date":"May 2, 2019","format":false,"excerpt":"Public Function GetBaseName( _ sFullFileNameWithExtension As String _ ) Dim fs As Object Set fs = CreateObject(\"Scripting.FileSystemObject\") GetBaseName = _ fs.GetBaseName( _ sFullFileNameWithExtension _ ) Set fs = Nothing 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":[]}],"_links":{"self":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts\/612","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=612"}],"version-history":[{"count":1,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts\/612\/revisions"}],"predecessor-version":[{"id":614,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts\/612\/revisions\/614"}],"wp:attachment":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/media?parent=612"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/categories?post=612"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/tags?post=612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}