Format cells to automatically change MAC Address to 00:00:00:00:00:00 format

Briant2468

New Member
Joined
Jun 26, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to set up a column to automatically change what ever is typed or pasted to be in a MAC Address format with the colons i.e. if typed or pasted 112233445566 it will show up as 11:22:33:44:55:66. I also want to copy the address and it be 11:22:33:44:55:66.
I have tried using =CONCATENATE(MID(A1,1,2),":",MID(A1,3,2),":",MID(A1,5,2),":",MID(A1,7,2),":",MID(A1,9,2),":",MID(A1,11,2)) and that does not work well.

I also have tried a VBA for the first time and it works good but if I apply it to an existing column I have to highlight each MAC and hit enter for the colons to show up. If I paste a column of MACs it formats the but it increases the MAC by 1 for each row like a pyramid (See picture below).

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range
Dim n As Long
Dim strTemp As String
Const csMONITOR_RANGE As String = "A1:A100"

On Error GoTo clean_up

If Not Intersect(Target, Range(csMONITOR_RANGE)) Is Nothing Then
Application.EnableEvents = False
For Each rngCell In Intersect(Target, Range(csMONITOR_RANGE)).Cells
If Len(rngCell.Value) = 12 Then
For n = 1 To 12 Step 2
strTemp = strTemp & ":" & Mid$(rngCell.Value, n, 2)
Next n
rngCell.Value = Mid$(strTemp, 2)
End If
Next rngCell
End If

clean_up:
Application.EnableEvents = True

End Sub

1624759345893.png


I assumed this would be something easy to do with MAC Address being entered a lot, but it is kicking my butt.

Thank You
Brian

Book1.xlsx
ABCDEFGH
1ExtensionInactive DaysDate TestedColumn1Old MACDescriptionNew MacNotes
28890106/23/202132F:E2:21:3B:88:21
388902104/15/2021822F:E2:21:3B:88:22
488903146/23/2021172F:E2:21:3B:88:22:2F:E2:21:3B:88:23
58890413811/17/20203592F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24
688905324/15/20211042F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25
788906174/15/2021892F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26
88890706/23/202132F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27
9889082314/15/20213032F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28
1088909906/23/2021932F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28:2F:E2:21:3B:88:29
11889108911/17/20203102F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28:2F:E2:21:3B:88:29:2F:E2:21:3B:88:30
128891106/23/202132F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28:2F:E2:21:3B:88:29:2F:E2:21:3B:88:30:2F:E2:21:3B:88:31
1388912904/15/20211622F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28:2F:E2:21:3B:88:29:2F:E2:21:3B:88:30:2F:E2:21:3B:88:31:2F:E2:21:3B:88:32
148891356/23/202182F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28:2F:E2:21:3B:88:29:2F:E2:21:3B:88:30:2F:E2:21:3B:88:31:2F:E2:21:3B:88:32:2F:E2:21:3B:88:33
15889149111/17/20203122F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28:2F:E2:21:3B:88:29:2F:E2:21:3B:88:30:2F:E2:21:3B:88:31:2F:E2:21:3B:88:32:2F:E2:21:3B:88:33:2F:E2:21:3B:88:34
1688915646/23/2021672F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28:2F:E2:21:3B:88:29:2F:E2:21:3B:88:30:2F:E2:21:3B:88:31:2F:E2:21:3B:88:32:2F:E2:21:3B:88:33:2F:E2:21:3B:88:34:2F:E2:21:3B:88:35
17889168711/17/20203082F:E2:21:3B:88:36
18889177411/17/20202952F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28:2F:E2:21:3B:88:29:2F:E2:21:3B:88:30:2F:E2:21:3B:88:31:2F:E2:21:3B:88:32:2F:E2:21:3B:88:33:2F:E2:21:3B:88:34:2F:E2:21:3B:88:35:2F:E2:21:3B:88:37
198891814711/17/20203682F:E2:21:3B:88:22:2F:E2:21:3B:88:23:2F:E2:21:3B:88:24:2F:E2:21:3B:88:25:2F:E2:21:3B:88:26:2F:E2:21:3B:88:27:2F:E2:21:3B:88:28:2F:E2:21:3B:88:29:2F:E2:21:3B:88:30:2F:E2:21:3B:88:31:2F:E2:21:3B:88:32:2F:E2:21:3B:88:33:2F:E2:21:3B:88:34:2F:E2:21:3B:88:35:2F:E2:21:3B:88:37:2F:E2:21:3B:88:38
2088919946/23/2021972F:E2:21:3B:88:39
Sheet1
Cell Formulas
RangeFormula
D2:D20D2=TODAY()-C2+B2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B20Cell Value>90textNO
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Welcome to MrExcel Message Board.
1. Formula Method:
Excel Formula:
=TEXTJOIN(":",,MID(A1,1,2),MID(A1,3,2),MID(A1,5,2),MID(A1,7,2),MID(A1,9,2),MID(A1,11,2))

2. VBA Method:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range
Dim n As Long
Dim strTemp As String
Const csMONITOR_RANGE As String = "A1:A100"

On Error GoTo clean_up

If Not Intersect(Target, Range(csMONITOR_RANGE)) Is Nothing Then
Application.EnableEvents = False
For Each rngCell In Intersect(Target, Range(csMONITOR_RANGE)).Cells
strTemp = ""
If Len(rngCell.Value) = 12 Then
For n = 1 To 12 Step 2
strTemp = strTemp & ":" & Mid$(rngCell.Value, n, 2)
Next n
rngCell.Value = Mid$(strTemp, 2)
End If
Next rngCell
End If

clean_up:
Application.EnableEvents = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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