Macro to toggle between 11-22 and 11:22

Modify_inc

Board Regular
Joined
Feb 26, 2009
Messages
77
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to create a macro that will toggle my column of MAC addresses between 11-22-33-44-55-66 and 11:22:33:44:55:66.

This is the command I am experimenting with, but it requires the results to be placed in a different cell, rather than convert the MAC in its current cell:

=SUBSTITUTE(G1,"-",":")

How would I apply this to a range of cells, like G25:G50

Any suggestions?

Mike
 

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
try:
Code:
Sub Test()
    Dim rng As Range
    For Each rng In Range("G25:G50")
        If InStr(rng, "-") Then
            rng = Replace(rng, "-", ":")
        Else
            rng = Replace(rng, ":", "-")
        End If
    Next rng
End Sub
 
Upvote 0
That worked great!
Thank you for taking the time to reply and providing the code for me to test.
 
Upvote 0
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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