Thread: inserting colon
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default inserting colon

Test Sub should of course be:

Sub test()

MsgBox InsertCharsInString("0014f8c49563", ":", 2)

End Sub

RBS


"RB Smissaert" wrote in message
...
Something like this will do it:

Function InsertCharsInString(strString As String, _
strInsert As String, _
lInterval As Long) As String

Dim lStart As Long
Dim strNew As String

lStart = -1

strNew = strString

Do While lStart < Len(strNew) - (lInterval + 1)
lStart = lStart + lInterval + 1
strNew = Left$(strNew, lStart) & _
strInsert & _
Mid$(strNew, lStart + 1)
Loop

InsertColons = strNew

End Function


Sub test()

MsgBox InsertColons("0014f8c49563", ":", 2)

End Sub


RBS


"xtrmhyper" wrote
in message ...

this is the data
0014f8c49563

how to insert colon automaticaly in every 2nd character

output is 00:14:f8:c4:95:63


--
xtrmhyper
------------------------------------------------------------------------
xtrmhyper's Profile:
http://www.excelforum.com/member.php...o&userid=23851
View this thread:
http://www.excelforum.com/showthread...hreadid=556466