跳到主要內容

如何在Excel中將列字母轉換為數字,反之亦然?

本文,我將討論如何將列字母轉換為列號或將列數字轉換為字母。 例如,將列字母AA轉換為數字27,或將列數字100轉換為字母CV。 用以下方法獲得解決方案。

使用公式將列字母轉換為數字,反之亦然

使用用戶定義的功能將列字母轉換為數字,反之亦然


箭頭藍色右氣泡 使用公式將列字母轉換為數字,反之亦然

要將列字母或標籤轉換為數字,反之亦然,以下公式可能會對您有所幫助,請執行以下操作:

將列字母轉換為列號:

請輸入以下公式: = COLUMN(INDIRECT(“ AB1”)) 放入要查找轉換結果的空白單元格,然後按 Enter 獲取列號的鍵:

doc將列標籤轉換為數字1

注意: 在上式中 AB 是您要獲取列號所基於的列字母,可以根據需要進行更改。

將列號轉換為列字母:

請輸入以下公式: = SUBSTITUTE(ADDRESS(1,200,4),1,“”) 放入空白單元格以獲取結果,然後按 Enter 獲取列字母,如下所示:

doc將列標籤轉換為數字2

注意: 在上面的公式中,紅色數字 200 是要轉換為列字母的列號,可以根據需要進行更改。


箭頭藍色右氣泡 使用用戶定義的功能將列字母轉換為數字,反之亦然

除了公式之外,在這裡我還可以介紹 用戶自定義函數 處理這個任務。

將列字母轉換為列號:

1。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications 窗口。

2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊 窗口。

VBA代碼:將列字母轉換為列號:

Public Function ToColNum(ColN)
    ToColNum = Range(ColN & 1).Column
End Function

3。 然後保存並關閉此代碼,返回到工作表,然後輸入以下公式: = Tocolnum(“ VV”) (VV 是要轉換數字的列字母。 )放入空白單元格,然後按 Enter 鍵以獲取列號,請參見屏幕截圖:

doc將列標籤轉換為數字3

將列號轉換為列字母:

1。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications 窗口。

2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊 窗口。

VBA代碼:將列號轉換為列字母:

Public Function ToColletter(Collet)
    ToColletter = Split(Cells(1, Collet).Address, "$")(1)
End Function

3。 然後保存並關閉此代碼,返回到工作表,然後輸入以下公式: = toColletter(50) (50 是要轉換為字母的列號。 )放入空白單元格,然後按 Enter 鍵以獲取列號,請參見屏幕截圖:

doc將列標籤轉換為數字4

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (10)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Public Function AlphabetInteger(ByVal letter As String) As Integer
Dim N As Integer
letter = Strings.UCase(letter)
If letter = "A" Then
N = 1
ElseIf letter = "B" Then
N = 2
ElseIf letter = "C" Then
N = 3
ElseIf letter = "D" Then
N = 4
ElseIf letter = "E" Then
N = 5
ElseIf letter = "F" Then
N = 6
ElseIf letter = "G" Then
N = 7
ElseIf letter = "H" Then
N = 8
ElseIf letter = "I" Then
N = 9
ElseIf letter = "J" Then
N = 10
ElseIf letter = "K" Then
N = 11
ElseIf letter = "L" Then
N = 12
ElseIf letter = "M" Then
N = 13
ElseIf letter = "N" Then
N = 14
ElseIf letter = "O" Then
N = 15
ElseIf letter = "P" Then
N = 16
ElseIf letter = "Q" Then
N = 17
ElseIf letter = "R" Then
N = 18
ElseIf letter = "S" Then
N = 19
ElseIf letter = "T" Then
N = 20
ElseIf letter = "U" Then
N = 21
ElseIf letter = "V" Then
N = 22
ElseIf letter = "W" Then
N = 23
ElseIf letter = "X" Then
N = 24
ElseIf letter = "Y" Then
N = 25
ElseIf letter = "Z" Then
N = 26
Else
N = 0
End If
AlphabetInteger = N
End Function


Public Function ColumnNumber(ByVal columnLetter As String) As Integer
Dim I As Integer
Dim sLength As Integer
Dim N As Integer
Dim A As Integer
Dim P As Integer
Dim C As String

sLength = Len(columnLetter)
N = 0
For I = 1 To sLength
P = sLength - I
C = Strings.Mid(columnLetter, I, 1)
A = AlphabetInteger(C)
N = N + A * 26 ^ P
Next I
ColumnNumber = N
End Function
This comment was minimized by the moderator on the site
Best solution =SUBSTITUTE(ADDRESS(1;COLUMN();4);1;"")
Thanks a lot.
Rated 5 out of 5
This comment was minimized by the moderator on the site
A to ZZ
=if(row()>26,char(row()/26+64)&char(mod(row(),26)+64),char(row()+64))
This comment was minimized by the moderator on the site
This formula does not work at rows that are multiples of 26. It gives B@ instead of AZ, C@ instead of BZ, D@ instead of CZ, etc.
Correction:= IF(ROW()>26,(IF(MOD(ROW(),26)=0,CHAR((ROW()-1)/26+64)&CHAR(MOD(ROW()-1,26)+65), CHAR(ROW()/26+64)&CHAR(MOD(ROW(),26)+64))),CHAR(ROW()+64))
This comment was minimized by the moderator on the site
thank you so much!!!...your formula to create the column letter to number really helps me a lot.
This comment was minimized by the moderator on the site
Function ToColletter(Collet) works as volatile function. If something changes anywhere in the sheet. It recalculate everywhere. In my case it makes 15 mil calculations and slowdown the calculation. Do you know how to fix it, if I dont want set application.calculation to manual and than back?
This comment was minimized by the moderator on the site
hola, cuando pego la formula = SUSTITUIR (DIRECCIÓN (1,200,4), 1, "") en una celda no hace nada, solo devuelve la formula, ya sea con 200 o cualquier otro numero
This comment was minimized by the moderator on the site
=CHAR(COLUMN( )+64)
This comment was minimized by the moderator on the site
Not better as it only works with 26 columns.
This comment was minimized by the moderator on the site
For so long I've used R1C1 cell referencing because I didn't know about the =SUBSTITUTE(ADDRESS(1,number,4),1,"") solution. Thank you!!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations