Thread: TEXT
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default TEXT

If the number of characters should not always be 15, then this code might
work to add the hyphen after the 10th character if one exists.

Sub addHyphen()
'Select Range manually, then run macro to add hyphen after
'the 10th character if it exists.
Dim cell As Range
For Each cell In Selection
If Len(cell.Value) 10 Then
cell.Value = Left(cell.Value, 10) & "-" & Mid(cell.Value, 11, 99)
Else: cell.Value = "'" & cell.Value
End If
Next cell
End Sub

Vaya con Dios,
Chuck, CABGx3



"adeel via OfficeKB.com" wrote:

I have large number of coding data like this (K4115KBA02WB005) these are 15
digits, what i want is to enter - sign after 10 digit (like K4115KBA02-WB005).
please tell me some short way.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200707/1