AlphaNumeric Cell Formatting

amdaar

New Member
Joined
Nov 15, 2006
Messages
2
How do I format a cell to display a MAC address in this format:

00-01-A3-E5-30-C1

I tried using the Format Cells...>Number>Custom option but I can't get it to format properly.

Thanks
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Can you not just insert a ' in front when you input? Alternatively if you're importing in, perhaps you could import & concatenate a ' at the front? Just a suggestion .. hope it helps.
 
Upvote 0
Hi, welcome to the board!

This can be done with VBA.
This is set for Column A, change as necessary.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range, d As Range, t(5) As String, s As String
Dim x As Integer
Set c = Intersect(Target, Range("A:A"))
If c Is Nothing Then Exit Sub
Application.EnableEvents = False
    For Each d In c
        s = Replace(d, "-", "")
        If s <> "" Then
            For x = 0 To 5
                t(x) = Mid(s, (x * 2) + 1, 2)
            Next x
            Target = UCase(Join(t, "-"))
        End If
    Next
Application.EnableEvents = True
End Sub
 
Upvote 0
Quick question. How do I go about implementing Visual Basic (I am assuming that is the previously posted code)? I am not quite that advanced to know how to implement it into Excel. Thanks.
 
Upvote 0
Copy the code above.
Right Click on the sheet tab for the sheet you want this to happen on.
Click on View Code.
Past the code into the white area.
Hit Alt-q
When you save the workbook, the code will be saved with it.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,854
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top