如何通过在Excel中添加冒号来格式化单元格中的mac地址?

网友投稿 721 2023-12-30

如何通过在Excel中添加冒号来格式化单元格中的mac地址?

假设您收到一个包含数字列表的工作表,现在您需要通过添加冒号将所有这些数字格式设置为mac地址,如下面的屏幕截图所示。 您能做什么来实现呢? 您可以尝试使用本教程中的方法来解决该问题。

通过在公式中添加冒号来格式化单元格中的mac地址

通过使用VBA添加冒号来格式化单元格中的mac地址

通过添加冒号轻松格式化单元格中的 mac 地址 Kutools for Excel
通过在公式中添加冒号来格式化单元格中的mac地址

下面的公式可以通过添加冒号来帮助您将数字格式设置为mac地址。 请执行以下操作。

1.选择一个空白单元格,在 配方栏,然后按 输入 键。 看截图:

=LEFT(A2,2)&":"&MID(A2,3,2)&":"&MID(A2,5,2)&":"&MID(A2,7,2)&":"&MID(A2,9,2)&":"&RIGHT(A2,2)

备注:在公式中,A2是包含您将要格式化为mac格式的数字的单元格。

2.选择第一个结果单元格,向下拖动“填充手柄”以获取所有mac格式编号。 看截图:

通过添加冒号轻松格式化单元格中的mac地址:

添加文本 实用程序 Kutools for Excel 可以帮助您轻松地将冒号添加到选定单元格的指定位置,以将数字格式化为mac地址格式。 看截图: 立即下载并试用! (30-天免费试用)

通过使用VBA添加冒号来格式化单元格中的mac地址

使用下面的VBA代码,您可以在Excel中一次将一系列数字格式化为mac地址。 请执行以下操作。

如何通过在Excel中添加冒号来格式化单元格中的mac地址?

1。 按 其他 + F11 同时打开 Microsoft Visual Basic应用程序 窗口。

2.在 Microsoft Visual Basic应用程序 窗口中,单击 插页 > 模块。 然后将下面的VBA代码复制到代码窗口中。

VBA代码:将数字格式设置为单元格中的mac地址

Sub FormatMAC() Dim I As Long Dim xRg As Range Dim xCell As Range Dim xVal As String Dim xStr As String On Error Resume Next Set xRg = Application.InputBox("Please select range:", "Kutools for Excel", Selection.Address, , , , , 8) If xRg Is Nothing Then Exit Sub For Each xCell In xRg xVal = xCell.Value If InStr(xVal, ":") > 0 Then xVal = Replace(xVal, ":", "") If Left(xVal, 1) = "0" Then xVal = Right(xVal, Len(xVal) - 1) End If For I = 1 To Int(Len(xVal) / 2) xStr = Mid(xVal, Len(xVal) + 1 - 2 * I, 2) & " " & xStr Next xStr = "0" & Mid(xVal, 1, 1) & " " & xStr xCell.Value = Left(Replace(xStr, " ", ":"), Len(xStr) - 1) xStr = "" Next End Sub
Copy
3. In the opening Kutools for Excel dialog box, please select the cells with numbers you will format as mac addresses, and then click the OK button. Then you can see all selected numbers are formatted as mac addresses as below screenshot shown. Easily format mac addresses in cells by adding colon with Kutools for Excel This section will introduce the Add Text utility of Kutoos for Excel. With this utility, you can quickly add colons to cells at specified positions. Please do as follows. Before applying Kutools for Excel, please download and install it firstly. 1. Select the cells you need to format as mac addresses. And then click Kutools > Text > Add Text. 2. In the Add Text dialog box, please type a colon into the Text box, select the Specify option, and then enter the specified position numbers into the box. And finally click the OK button. Note: In this case, I need to add colons after every two numbers in cells, so I enter 2, 4, 6, 8 and 10 and separate them by commas. See screenshot: If you want to have a free trial (30-day) of this utility, please click to download it, and then go to apply the operation according above steps. Related articles: How to add text in middle of selected cells in Excel? How to add comma at end of cell/text in Excel? How to add a character before each Word in a cell in Excel? Best Office Productivity Tools Transform Hours into Minutes with Kutools for Excel! Ready to supercharge your Excel tasks? Harness the power of Kutools for Excel - your ultimate time-saving tool. Streamline intricate tasks and glide through your data like a pro. Experience Excel at lightning speed! Why You Need Kutools for Excel 🛠️ Over 300 Powerful Features: Kutools is packed with more than 300 advanced features, simplifying your work in over 1500 scenarios. 📈 Superior Data Processing: Merge cells, remove duplicates, and perform advanced data conversions – all without breaking a sweat! ⏱️ Efficient Batch Operations: Why put in extra effort when you can work smart? Import, export, combine, and tweak data in bulk with ease. 📊 Customizable Charts and Reports: Access a broad variety of additional charts and generate insightful reports that tell a story. 🗄️ Powerful Navigation Pane: Gain an advantage with the robust Column Manager, Worksheet Manager, and Custom Favorites. 📝 Seven Types of Drop-down Lists: Make data entry a breeze with drop-down lists of various features and types. 🎓 User-Friendly: A breeze for beginners and a powerful tool for experts. Download Now and Soar Through Time with Excel! Read More... Free Download... Purchase... Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project. Open and create multiple documents in new tabs of the same window, rather than in new windows. Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day! Read More... Free Download... Purchase...

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:如何在Excel中设置引线格式?
下一篇:如何在Excel中将数字格式设置为序数(1st 2nd 3rd)?
相关文章