<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Column Letters To Numbers</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Thu, 09 Feb 2012 23:42:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Superplanilla</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1686</link>
		<dc:creator>Superplanilla</dc:creator>
		<pubDate>Tue, 08 Jun 2004 00:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1686</guid>
		<description>&lt;p&gt;Otra variante:&lt;/p&gt;
&lt;p&gt;Function colnum(x)&lt;br&gt;
colnum = Range(x &amp; &quot;:&quot; &amp; x).Column&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Otra variante:</p>
<p>Function colnum(x)<br />
colnum = Range(x &amp; &#8220;:&#8221; &amp; x).Column<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary Waters</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1685</link>
		<dc:creator>Gary Waters</dc:creator>
		<pubDate>Mon, 07 Jun 2004 23:55:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1685</guid>
		<description>&lt;p&gt;Dick, here&#039;s a function that includes error checking and covers all positive long integers:&lt;br&gt;
Function ColumnNumber(ByVal strCol As String) As Long&lt;br&gt;
    Dim length As Long, i As Long&lt;br&gt;
    strCol = UCase(strCol)&lt;br&gt;
    length = Len(strCol)&lt;br&gt;
    If length &lt; 1 Or length &gt; 7 Then&lt;br&gt;
        ColumnNumber = -1&lt;br&gt;
        Exit Function&lt;br&gt;
    End If&lt;br&gt;
    If Not strCol Like Replace(Space(length), &quot; &quot;, &quot;[A-Z]&quot;) Then&lt;br&gt;
        ColumnNumber = -1&lt;br&gt;
        Exit Function&lt;br&gt;
    End If&lt;br&gt;
    If length = 7 Then&lt;br&gt;
        If strCol &gt; &quot;FXSHRXW&quot; Then&lt;br&gt;
            ColumnNumber = -1&lt;br&gt;
            Exit Function&lt;br&gt;
        End If&lt;br&gt;
    End If&lt;br&gt;
    ColumnNumber = 0&lt;br&gt;
    For i = 1 To length&lt;br&gt;
        ColumnNumber = ColumnNumber + (Asc(Mid$(strCol, i, 1)) - 64) * 26 ^ (length - i)&lt;br&gt;
    Next i&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Dick, here&#8217;s a function that includes error checking and covers all positive long integers:<br />
Function ColumnNumber(ByVal strCol As String) As Long<br />
    Dim length As Long, i As Long<br />
    strCol = UCase(strCol)<br />
    length = Len(strCol)<br />
    If length &lt; 1 Or length &gt; 7 Then<br />
        ColumnNumber = -1<br />
        Exit Function<br />
    End If<br />
    If Not strCol Like Replace(Space(length), &#8221; &#8220;, &#8220;[A-Z]&#8220;) Then<br />
        ColumnNumber = -1<br />
        Exit Function<br />
    End If<br />
    If length = 7 Then<br />
        If strCol &gt; &#8220;FXSHRXW&#8221; Then<br />
            ColumnNumber = -1<br />
            Exit Function<br />
        End If<br />
    End If<br />
    ColumnNumber = 0<br />
    For i = 1 To length<br />
        ColumnNumber = ColumnNumber + (Asc(Mid$(strCol, i, 1)) &#8211; 64) * 26 ^ (length &#8211; i)<br />
    Next i<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron de Bruin</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1684</link>
		<dc:creator>Ron de Bruin</dc:creator>
		<pubDate>Mon, 07 Jun 2004 20:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1684</guid>
		<description>&lt;p&gt;Try this&lt;/p&gt;
&lt;p&gt;Also from Chip I believe&lt;/p&gt;
&lt;p&gt;Function ColumnNumber(ColLetter) As Integer&lt;br&gt;
    ColumnNumber = Cells(1, ColLetter).Column&lt;br&gt;
End Function&lt;/p&gt;
&lt;p&gt;Temp = ColumnNumber(&quot;D&quot;)    &#039; returns 4&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Try this</p>
<p>Also from Chip I believe</p>
<p>Function ColumnNumber(ColLetter) As Integer<br />
    ColumnNumber = Cells(1, ColLetter).Column<br />
End Function</p>
<p>Temp = ColumnNumber(&#8220;D&#8221;)    &#8216; returns 4</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tjs</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1683</link>
		<dc:creator>tjs</dc:creator>
		<pubDate>Mon, 07 Jun 2004 18:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1683</guid>
		<description>&lt;p&gt;David,&lt;br&gt;
this eliminates the extra math. i.e. (26 * (LenColLetter - i)&lt;/p&gt;
&lt;p&gt;Function ColNum(ByVal ColumnLetter As String) As Long&lt;br&gt;
Dim LenColLetter As Integer, i As Integer&lt;br&gt;
ColNum = 0: LenColLetter = Len(ColumnLetter)&lt;br&gt;
For i = 1 To LenColLetter&lt;br&gt;
    ColNum = ColNum * 26 + (Asc(UCase(Mid(ColumnLetter, i, 1))) - 64)&lt;br&gt;
Next i&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>David,<br />
this eliminates the extra math. i.e. (26 * (LenColLetter &#8211; i)</p>
<p>Function ColNum(ByVal ColumnLetter As String) As Long<br />
Dim LenColLetter As Integer, i As Integer<br />
ColNum = 0: LenColLetter = Len(ColumnLetter)<br />
For i = 1 To LenColLetter<br />
    ColNum = ColNum * 26 + (Asc(UCase(Mid(ColumnLetter, i, 1))) &#8211; 64)<br />
Next i<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1682</link>
		<dc:creator>Dick</dc:creator>
		<pubDate>Mon, 07 Jun 2004 18:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1682</guid>
		<description>&lt;p&gt;David:  I think you need to get rid of the +1.  ?ColNum(&quot;a&quot;) = 2.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>David:  I think you need to get rid of the +1.  ?ColNum(&#8220;a&#8221;) = 2.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald Staff</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1681</link>
		<dc:creator>Harald Staff</dc:creator>
		<pubDate>Mon, 07 Jun 2004 18:30:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1681</guid>
		<description>&lt;p&gt;David&lt;/p&gt;
&lt;p&gt;THis is good. But I get &quot;2? as a result of &quot;A&quot;. After removing the +1 it said 1. I ran this, combining the two:&lt;/p&gt;
&lt;p&gt;Sub test()&lt;br&gt;
Dim L As Long, L2 As Long, S As String&lt;br&gt;
L = 0&lt;br&gt;
Do&lt;br&gt;
L = L + 1&lt;br&gt;
    S = ColumnLetter(L)&lt;br&gt;
    L2 = colNum(S)&lt;br&gt;
    If L2 &lt;&gt; L Then&lt;br&gt;
        MsgBox L &amp; &quot; vs &quot; &amp; L2, , S&lt;br&gt;
        Exit Sub&lt;br&gt;
    End If&lt;br&gt;
Loop Until L &gt; 1000000&lt;br&gt;
MsgBox S, , L&lt;br&gt;
End Sub&lt;/p&gt;
&lt;p&gt;No error. So either both are great or both are equally wrong. Unfortunately I have only 256 columns to check against :-)&lt;/p&gt;
&lt;p&gt;Best wishes Harald&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>David</p>
<p>THis is good. But I get &#8220;2? as a result of &#8220;A&#8221;. After removing the +1 it said 1. I ran this, combining the two:</p>
<p>Sub test()<br />
Dim L As Long, L2 As Long, S As String<br />
L = 0<br />
Do<br />
L = L + 1<br />
    S = ColumnLetter(L)<br />
    L2 = colNum(S)<br />
    If L2 &lt;&gt; L Then<br />
        MsgBox L &amp; &#8221; vs &#8221; &amp; L2, , S<br />
        Exit Sub<br />
    End If<br />
Loop Until L &gt; 1000000<br />
MsgBox S, , L<br />
End Sub</p>
<p>No error. So either both are great or both are equally wrong. Unfortunately I have only 256 columns to check against <img src='http://www.dailydoseofexcel.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Best wishes Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Wasserman</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1680</link>
		<dc:creator>David Wasserman</dc:creator>
		<pubDate>Mon, 07 Jun 2004 17:03:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1680</guid>
		<description>&lt;p&gt;Oops, the 5th line should read:&lt;/p&gt;
&lt;p&gt;ColNum = ColNum + (26 ^(LenColLetter - i) * (Asc(UCase(Mid(ColumnLetter, i, 1))) - 64)) + 1&lt;/p&gt;
&lt;p&gt;The difference is power vs multiplication.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Oops, the 5th line should read:</p>
<p>ColNum = ColNum + (26 ^(LenColLetter &#8211; i) * (Asc(UCase(Mid(ColumnLetter, i, 1))) &#8211; 64)) + 1</p>
<p>The difference is power vs multiplication.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Wasserman</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1679</link>
		<dc:creator>David Wasserman</dc:creator>
		<pubDate>Mon, 07 Jun 2004 16:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1679</guid>
		<description>&lt;p&gt;This function will work even if Microsoft expands the columns to allow three or more letters:&lt;/p&gt;
&lt;p&gt;Function ColNum(ByVal ColumnLetter As String) As Long&lt;br&gt;
Dim LenColLetter As Integer, i As Integer&lt;br&gt;
    ColNum = 0: LenColLetter = Len(ColumnLetter)&lt;br&gt;
    For i = 1 To LenColLetter&lt;br&gt;
        ColNum = ColNum + (26 * (LenColLetter - i) * (Asc(UCase(Mid(ColumnLetter, i, 1))) - 64)) + 1&lt;br&gt;
    Next i&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This function will work even if Microsoft expands the columns to allow three or more letters:</p>
<p>Function ColNum(ByVal ColumnLetter As String) As Long<br />
Dim LenColLetter As Integer, i As Integer<br />
    ColNum = 0: LenColLetter = Len(ColumnLetter)<br />
    For i = 1 To LenColLetter<br />
        ColNum = ColNum + (26 * (LenColLetter &#8211; i) * (Asc(UCase(Mid(ColumnLetter, i, 1))) &#8211; 64)) + 1<br />
    Next i<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CJM</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1678</link>
		<dc:creator>CJM</dc:creator>
		<pubDate>Mon, 07 Jun 2004 16:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1678</guid>
		<description>&lt;p&gt;Apologies for the formatting, the indents seem to fall out when it gets posted...&lt;/p&gt;
&lt;p&gt;=======================================&lt;/p&gt;
&lt;p&gt;Function ColNum(ByVal ColumnLetter As String) As Long&lt;br&gt;
&#039;Returns the column reference if valid.  If reference is&lt;br&gt;
&#039;invalid, returns 0.&lt;br&gt;
    ColNum = 0&lt;br&gt;
    If Len(ColumnLetter) = 2 Then&lt;br&gt;
        If ValidColumn(Left(ColumnLetter, 1), False) And _&lt;br&gt;
          ValidColumn(Right(ColumnLetter, 1), True) Then&lt;br&gt;
            ColNum = ThisWorkbook.Sheets(1).Range(ColumnLetter &amp; &quot;1?).Column&lt;br&gt;
        Else&lt;br&gt;
            ColNum = 0&lt;br&gt;
        End If&lt;br&gt;
    ElseIf Len(ColumnLetter) = 1 Then&lt;br&gt;
        If ValidColumn(Left(ColumnLetter, 1), False) Then&lt;br&gt;
            ColNum = ThisWorkbook.Sheets(1).Range(ColumnLetter &amp; &quot;1?).Column&lt;br&gt;
        Else&lt;br&gt;
            ColNum = 0&lt;br&gt;
        End If&lt;br&gt;
    End If&lt;br&gt;
End Function&lt;/p&gt;
&lt;p&gt;Function ValidColumn(TestChar As String, IVTest As Boolean) As Boolean&lt;br&gt;
    ValidColumn = False&lt;br&gt;
    If IVTest Then&lt;br&gt;
        If Asc(UCase(TestChar)) &gt;= 65 And Asc(UCase(TestChar)) &lt; = 86 Then&lt;br&gt;
            ValidColumn = True&lt;br&gt;
        End If&lt;br&gt;
    Else&lt;br&gt;
        If Asc(UCase(TestChar)) &gt;= 65 And Asc(UCase(TestChar)) &lt;= 90 Then&lt;br&gt;
            ValidColumn = True&lt;br&gt;
        End If&lt;br&gt;
    End If&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Apologies for the formatting, the indents seem to fall out when it gets posted&#8230;</p>
<p>=======================================</p>
<p>Function ColNum(ByVal ColumnLetter As String) As Long<br />
&#8216;Returns the column reference if valid.  If reference is<br />
&#8216;invalid, returns 0.<br />
    ColNum = 0<br />
    If Len(ColumnLetter) = 2 Then<br />
        If ValidColumn(Left(ColumnLetter, 1), False) And _<br />
          ValidColumn(Right(ColumnLetter, 1), True) Then<br />
            ColNum = ThisWorkbook.Sheets(1).Range(ColumnLetter &amp; &#8220;1?).Column<br />
        Else<br />
            ColNum = 0<br />
        End If<br />
    ElseIf Len(ColumnLetter) = 1 Then<br />
        If ValidColumn(Left(ColumnLetter, 1), False) Then<br />
            ColNum = ThisWorkbook.Sheets(1).Range(ColumnLetter &amp; &#8220;1?).Column<br />
        Else<br />
            ColNum = 0<br />
        End If<br />
    End If<br />
End Function</p>
<p>Function ValidColumn(TestChar As String, IVTest As Boolean) As Boolean<br />
    ValidColumn = False<br />
    If IVTest Then<br />
        If Asc(UCase(TestChar)) &gt;= 65 And Asc(UCase(TestChar)) &lt; = 86 Then<br />
            ValidColumn = True<br />
        End If<br />
    Else<br />
        If Asc(UCase(TestChar)) &gt;= 65 And Asc(UCase(TestChar)) &lt;= 90 Then<br />
            ValidColumn = True<br />
        End If<br />
    End If<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Pope</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/06/07/column-letters-to-numbers/#comment-1677</link>
		<dc:creator>Andy Pope</dc:creator>
		<pubDate>Mon, 07 Jun 2004 16:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=607#comment-1677</guid>
		<description>&lt;p&gt;How about,&lt;/p&gt;
&lt;p&gt;Function ColNum(ByVal ColumnLetter As String) As Long&lt;br&gt;
    On Error Resume Next&lt;br&gt;
    ColNum = Range(ColumnLetter &amp; &quot;1?).Column&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>How about,</p>
<p>Function ColNum(ByVal ColumnLetter As String) As Long<br />
    On Error Resume Next<br />
    ColNum = Range(ColumnLetter &amp; &#8220;1?).Column<br />
End Function</p>
]]></content:encoded>
	</item>
</channel>
</rss>

