Place ** before and after the number

niladri20052006

Board Regular
Joined
Dec 3, 2010
Messages
121
Hi All,

I have a number like in one cell. Is it possible to place ** before and after each number

<table style="width: 179px; height: 40px;" border="0" cellpadding="0" cellspacing="0"><col width="150"><tr height="20"> <td style="height: 15pt; width: 113pt;" width="150" height="20">,408,650,831,415, 925 </td> </tr></table>
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
,408,650,831,415, 925

Are these 5 cells or 1?
 
Upvote 0
Try something like this code:

Code:
Function WithStars(s As String)
    sq = Split(s, ",")
    For i = 0 To UBound(sq)
        If IsNumeric(Trim(sq(i))) Then soutput = soutput & "**,**" & Trim(sq(i))
    Next
    WithStars = Mid(soutput, 3) & "**"
End Function

Paste it in a normal module of your workbook. Then you can use the function in the sheet as follows:

=WithStars(A1)

if you want to let the function act on cell A1. Suit if needed.

Wigi
 
Upvote 0
As a UDF:

Code:
Function WithStars(r As String) As String
Dim t
r = Replace(r, " ", "")
t = Split(r, ",")
WithStars = Join(t, "*") & "*"
End Function

As a formula:

=SUBSTITUTE(SUBSTITUTE(A1," ",""),",","*")&"*"
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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