View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default inserting colon into a value at a specific interval

Another one -

Sub Test()
Dim sFormat As String, sText As String
Dim cel As Range
Dim rng As Range

sFormat = "@@:@@:@@:@@:@@:@@"

Set rng = Selection

For Each cel In rng
sText = Replace(cel, ":", "")
cel = Format(sText, Left(sFormat, Len(sText) * 1.5))
Next

End Sub

Sub TestTheTest()
Dim i&, s$
For i = 1 To 12
s = s & Chr(64 + i)
Cells(i, 1) = s
Next
Range("A1").CurrentRegion.Select

Test
' should be OK to run Test again over processed cells
' Test
End Sub

Regards,
Peter T


wrote in message
ups.com...
I've got a spreadsheet with a list of alphanumeric values:

62:EF:62:EF:9C4A
62:EF:62:EF:B09B
62:EF:62:EF:A0F4
62:EF:62:EF:AF71
62:EF:62:EF:B309

I'm trying to find a way to insert a colon between the final four
characters, so that they are separated into two pairs so that the
outcome is:

62:EF:62:EF:9C:4A
62:EF:62:EF:B0:9B
62:EF:62:EF:A0:F4
62:EF:62:EF:AF:71
62:EF:62:EF:B3:09

I've used file/folder renaming utilities before that allow you to
insert or replace a value by counting so many spaces from the
beginning or the end of a value, but I don't know how to do this in
Excel. I also use the freeware ASAP utilities frequently, but don't
see a way to do this. Any suggestions?

Thanks!