Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default inserting colon


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default inserting colon

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default inserting colon


i dont any idea for that command

any formula in excel?


tnx in advace:

--
xtrmhype
-----------------------------------------------------------------------
xtrmhyper's Profile: http://www.excelforum.com/member.php...fo&userid=2385
View this thread: http://www.excelforum.com/showthread.php?threadid=55646

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default inserting colon

There is no command in Excel, that's why you need to write your own.

Make that code a Public Function in a module, then you can call it from the
worksheet with:
e.g. in cell A1, "=InsertCharsInString("0014f8c49563", ":", 2)"

Google for "Excel User defined function", you get a lot of help.

NickHK

"xtrmhyper" wrote
in message ...

i dont any idea for that command

any formula in excel?


tnx in advace:)


--
xtrmhyper
------------------------------------------------------------------------
xtrmhyper's Profile:

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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default inserting colon

If you know the string will be exactly 12 bytes long then you
can use the worksheet formula :

=MID(A1,1,2)&":"&MID(A1,3,2)&":"&MID(A1,5,2)&":"&M ID(A1,7,2)&":"&MID(A1,9,2)&":"&MID(A1,11,2)


NickHK wrote:
There is no command in Excel, that's why you need to write your own.

Make that code a Public Function in a module, then you can call it from the
worksheet with:
e.g. in cell A1, "=InsertCharsInString("0014f8c49563", ":", 2)"

Google for "Excel User defined function", you get a lot of help.

NickHK

"xtrmhyper" wrote
in message ...

i dont any idea for that command

any formula in excel?


tnx in advace:)


--
xtrmhyper
------------------------------------------------------------------------
xtrmhyper's Profile:

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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default inserting colon


tnx anyway?

how about concatenate?


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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default inserting colon

Concatenate what ?

NickHK

"xtrmhyper" wrote
in message ...

tnx anyway?

how about concatenate?


--
xtrmhyper
------------------------------------------------------------------------
xtrmhyper's Profile:

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



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default inserting colon


tnx
Andrew Taylor

it works:)

GOD SPEED:

--
xtrmhype
-----------------------------------------------------------------------
xtrmhyper's Profile: http://www.excelforum.com/member.php...fo&userid=2385
View this thread: http://www.excelforum.com/showthread.php?threadid=55646

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
format colon Pammy Excel Discussion (Misc queries) 2 March 24th 09 08:48 PM
how to change colon to semi-colon in CP/List Seprator Khoshravan Excel Discussion (Misc queries) 3 February 4th 09 07:41 PM
Center on colon WJason Excel Discussion (Misc queries) 3 August 20th 07 09:54 PM
Add colon to times meridklt New Users to Excel 4 May 11th 07 09:36 PM
Colon in code? davegb Excel Programming 4 January 13th 06 04:09 PM


All times are GMT +1. The time now is 09:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"