{"id":150,"date":"2005-10-28T22:08:38","date_gmt":"2005-10-28T21:08:38","guid":{"rendered":"http:\/\/www.craigmurphy.com\/blog\/?p=150"},"modified":"2005-11-22T19:20:44","modified_gmt":"2005-11-22T18:20:44","slug":"excel-column-number-to-letters","status":"publish","type":"post","link":"https:\/\/www.craigmurphy.com\/blog\/?p=150","title":{"rendered":"Excel: Column Number to Letter(s)"},"content":{"rendered":"<p>I found myself working inside Excel this week, doing a little bit of VBA&#8230;<\/p>\n<p>It has been a while since I had to work inside this environment, my memory was stretched as I tried to remember what code I had already written (short libraries), etc.  My troubles were compounded by the fact that the machine I was using did not have the VBA Help for Excel installed, so I was relying on my memory&#8230;which isn&#8217;t a good thing!<\/p>\n<p>So I&#8217;m grateful for the existence of <a href=\"http:\/\/www.dicks-blog.com\">Dick&#8217;s Blog<\/a> and in particular this <a href=\"http:\/\/www.dicks-blog.com\/archives\/2004\/05\/21\/column-numbers-to-letters\/\">post<\/a>.<\/p>\n<p>I had the need to convert a column number into it&#8217;s alphabetic counter-part&#8230;e.g. ColumnLetter(1) returns A&#8230;I was pleased to find this code snippet over at Dick&#8217;s blog:<\/p>\n<p><code>Function ColumnLetter(ByVal colNum As Long) As String<br \/>\nDim i As Long, x As Long<br \/>\n  For i = Int(Log(CDbl(25 * (CDbl(colNum) + 1))) \/ Log(26)) - 1 To 0 Step -1<br \/>\n    x = (26 ^ (i + 1) - 1) \/ 25 - 1<br \/>\n    If colNum > x Then<br \/>\n      ColumnLetter = ColumnLetter & Chr(((colNum - x - 1) \\ 26 ^ i) Mod 26 + 65)<br \/>\n    End If<br \/>\n  Next i<br \/>\nEnd Function<\/code><\/p>\n<p>It was just the ticket &#8211; thanks Dick!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dick&#8217;s Blog prove very useful&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-development"],"_links":{"self":[{"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=150"}],"version-history":[{"count":0,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}