跳到主要内容

如何在Excel中将列字母转换为数字,反之亦然?

本文,我将讨论如何将列字母转换为列号或将列数字转换为字母。 例如,将列字母AA转换为数字27,或将列数字100转换为字母CV。 用以下方法获得解决方案。

使用公式将列字母转换为数字,反之亦然

使用用户定义的功能将列字母转换为数字,反之亦然


箭头蓝色右气泡 使用公式将列字母转换为数字,反之亦然

要将列字母或标签转换为数字,反之亦然,以下公式可能会对您有所帮助,请执行以下操作:

将列字母转换为列号:

请输入以下公式: = COLUMN(INDIRECT(“ AB1”)) 放入要查找转换结果的空白单元格,然后按 输入 获取列号的键:

doc将列标签转换为数字1

请注意: 在上式中 AB 是您要获取列号所依据的列字母,可以根据需要进行更改。

将列号转换为列字母:

请输入以下公式: = SUBSTITUTE(ADDRESS(1,200,4),1,“”) 放入空白单元格以获取结果,然后按 输入 获取列字母,如下所示:

doc将列标签转换为数字2

请注意: 在上面的公式中,红色数字 200 是要转换为列字母的列号,可以根据需要进行更改。


箭头蓝色右气泡 使用用户定义的功能将列字母转换为数字,反之亦然

除了公式之外,在这里我还可以介绍 用户定义功能 处理这个任务。

将列字母转换为列号:

1。 按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

2。 点击 插页 > 模块,然后将以下代码粘贴到 模块 窗口。

VBA代码:将列字母转换为列号:

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

3。 然后保存并关闭此代码,返回到工作表,然后输入以下公式: = Tocolnum(“ VV”) (VV 是要转换数字的列字母。 )放入空白单元格,然后按 输入 键以获取列号,请参见屏幕截图:

doc将列标签转换为数字3

将列号转换为列字母:

1。 按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

2。 点击 插页 > 模块,然后将以下代码粘贴到 模块 窗口。

VBA代码:将列号转换为列字母:

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

3。 然后保存并关闭此代码,返回到工作表,然后输入以下公式: = toColletter(50) (50 是要转换为字母的列号。 )放入空白单元格,然后按 输入 键以获取列号,请参见屏幕截图:

doc将列标签转换为数字4

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 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