跳到主要内容

如何在Excel中将月份名称转换为数字?

有时,您可能希望将月份名称转换为数字或将数字转换为月份名称,例如在Excel中将一月转换为1,可以使用公式和VBA在月份名称和数字之间快速转换。
doc月名称为1

在Excel中将月份名称转换为数字

使用VBA将数字转换为月份名称

使用 Kutools for Excel 将日期转换为月份名称或月份编号 好主意3


箭头蓝色右气泡 在Excel中将月份名称转换为数字

有两种方法可以帮助您在Excel中将月份名称转换为数字。

方法1:使用公式将月份名称转换为数字。

输入此公式 = MONTH(DATEVALUE(A1&“ 1”)) (A1表示您想要将月份名称转换为数字的单元格,可以根据需要进行更改)成一个空白单元格,然后按 输入 键。 看截图:
doc月名称为2

如果要将月份名称的列列表转换为数字,只需拖动公式单元格的填充手柄即可填充所需的范围。 看截图:
doc月名称为3

方法2:使用VBA将月份名称转换为数字

1.按住 ALT 按钮并按下 F11 在键盘上打开一个 Microsoft Visual Basic应用程序 窗口。

2。 点击 插页 > e,然后将VBA复制到模块中。

VBA:将月份名称转换为数字

Sub ChangeNum()
'Updateby20140311
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    If Rng.Value <> "" Then
        Rng.Value = Month(DateValue("03/" & Rng.Value & "/2014"))
    End If
Next
End Sub

3。 点击 运行 运行VBA代码,以及 KutoolsForexcel. 弹出对话框,选择要转换为数字的月份名称的单元格区域,然后单击“确定”,已选择的月份名称已转换为月份数字。 看截图:
doc月名称为4

Tips:注意:使用上述VBA可能会丢失原始数据,可以在运行VBA代码之前保存它们。

在Excel中快速轻松地将日期转换为其他日期格式

您是否曾经尝试过将日期仅转换为日,月或年? 公式可能很难记住,但是 套用日期格式 of Kutools for Excel 可以根据需要将标准日期快速转换为日期格式,如下图所示。 不要,服务员, 点击获取30天免费试用!
doc申请日期格式
 
Kutools for Excel:拥有300多个便捷的Excel加载项,可以在30天内免费试用。

箭头蓝色右气泡 使用VBA将数字转换为月份名称

相反,如果要将数字转换为月份名称,也可以使用两种方法来解决。

方法1:使用公式将数字转换为月份名称。

输入此公式 = TEXT(DATE(2000,A1,1),“ mmmm”) (A1表示要将数字转换为月份名称的单元格,可以根据需要进行更改)成空白单元格,然后按 输入 键。 看截图:
doc月名称为5

如果要将列的数字列表转换为月份名称,只需拖动公式单元格的填充手柄即可填充所需的范围。 看截图:
doc月名称为6

Tips::如果要将数字转换为月份名称的缩写,可以使用此公式 = TEXT(DATE(2000,A1,1),“ mmm”).
doc月名称为7

方法2:使用VBA将数字转换为月份名称

1.按住 ALT 按钮并按下 F11 在键盘上打开一个 Microsoft Visual Basic应用程序 窗口。

2。 点击 插页 > 模块,然后将VBA复制到模块中。

VBA:将数字转换为月份名称

Sub ChangeMonth()
'Updateby20140311
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    Rng.Value = VBA.Format(Rng.Value * 29, "mmmm")
Next
End Sub

3。 点击 运行 运行VBA代码,以及 KutoolsForexcel. 弹出对话框,选择要转换为月份名称的数字范围的单元格。 然后单击确定,数字已转换为相应的月份名称。 看截图:
doc月名称为8

Tips::

1.使用上述VBA可能会丢失您的原始数据,可以在运行VBA代码之前将其保存。

2.如果要将数字转换为月份名称的缩写,可以在上述VBA中将“ mmmm”更改为“ mmm”。


箭头蓝色右气泡 使用 Kutools for Excel 将日期转换为月份名称或月份编号

如果您在工作表中有日期列表,需要将其转换为月份名称或月份编号,则可以应用 Kutools for Excel套用日期格式 效用。

Kutools for Excel, 与超过 300 方便的功能,使您的工作更加轻松。 

免费安装 Kutools for Excel,请执行以下操作:

1.选择日期,然后单击 库工具 > 格式 > 套用日期格式。 看截图:
doc套用日期格式1

2.然后在弹出的对话框中,从中选择所需的日期格式。 日期格式 列表,您可以从 预览 窗格。
doc套用日期格式2

3。 然后点击 Ok or 使用,您可以看到日期已转换为相对的月份名称或月份数字。
doc套用日期格式3

单击此处以了解有关“申请日期格式”的更多信息

箭头蓝色右气泡 将日期转换为月份编号或月份名称或其他日期格式


快速将非标准日期转换为标准日期格式(mm / dd / yyyy)

在某些情况下,您可能会收到带有多个非标准日期的工作清单,并将它们全部转换为标准日期格式,如mm / dd / yyyy可能会给您带来麻烦。 这里 Kutools for Excel's 转换至今 一键即可将这些非标准日期快速转换为标准日期格式。  点击即可获得 30 天的免费全功能试用!
doc转换日期
 
Kutools for Excel:拥有300多个便捷的Excel加载项,可以在30天内免费试用。

最佳办公生产力工具

🤖 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 (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Cute solution, using datevalue. Took me a minute to figure it out. "Jan" is a random piece of text. The "&1" turns it into "Jan 1," which is a date upon which datevalue can do it's magic. Clever solution. :)
This comment was minimized by the moderator on the site
DATEVALUE wouldn't work with most of the local date formats.
This comment was minimized by the moderator on the site
wf = one week from now mf= one month from the entry 2mf= 2 months from the entry 4mf= 4 months from the entry 6mf= 6 months from the entry yf= one year from the entry I am wondering if possible to covert this entry in another column as due dates.
This comment was minimized by the moderator on the site
If you pre-filling the month names, did you try using a vlookup instead of using a VBA?
This comment was minimized by the moderator on the site
Thank you It works in my case
This comment was minimized by the moderator on the site
This is funny. Following Function converts the Filename which is Month Name to its corresponding Numerical value =MONTH(1&LEFT((MID(CELL("filename",A1),SEARCH("[",CELL("filename",A1))+1,SEARCH(".",CELL("filename",A1))-1-SEARCH("[",CELL("filename",A1)))),3))
This comment was minimized by the moderator on the site
Excel function MONTH: does it get the number from text for example from NOV it would get 11, or: the text from the number for example from 11 it would get NOV, or what? On my location it goes from 11 to 11, not very interesting!!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations