search for 1st non * in text

winde

New Member
Joined
Nov 27, 2018
Messages
32
Hi

Can i know how to find the first non "*" in a cell and return all the text after that?


example:

*****ant --> ant

**Bat --> Bat

*********cat --> cat


Thanks.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Assuming there will be no asterisks in the remaining text that you are after...

=SUBSTITUTE(A1,"*","")
 
Upvote 0
Assuming there will be no asterisks in the remaining text that you are after...

=SUBSTITUTE(A1,"*","")


Hi Rick

Problem is..there is..so i had some text like the following.

example:

******bat*en

I only need to remove all the "*" that is before the first letter.

Thanks.
 
Upvote 0
Hi Rick

Problem is..there is..so i had some text like the following.

example:

******bat*en

I only need to remove all the "*" that is before the first letter.

Will your text ever have any spaces in them?
 
Upvote 0
Will your text ever have any spaces in them?

yup. there are spaces in between.

i am trying to clean up the data which is in a mess now. and the first step is the remove the "*"s in front of the texts.

i'm looking at both using formula and vba. not sure which one is easier to apply to my data
 
Last edited:
Upvote 0
You could use something like:

=MID(A1,FIND(LEFT(SUBSTITUTE(A1,"*",""),1),A1),LEN(A1))
 
Upvote 0
You could use something like:

=MID(A1,FIND(LEFT(SUBSTITUTE(A1,"*",""),1),A1),LEN(A1))


Thanks! it worked.

Could you help explain the formula? I get how individual function works..but not when combining them together
 
Upvote 0
Thanks! it worked.
Here is the VBA version that you mentioned you might want to use...
Code:
[table="width: 500"]
[tr]
	[td]AfterLeadingAsterisks = Right(Range("A1"), Len(LTrim(Replace(Range("A1"), "*", " "))))[/td]
[/tr]
[/table]
 
Upvote 0
Sure.
SUBSTITUTE(A1,"*",""),
replaces all the asterisks with nothing. The LEFT function returns the first character of the result of that - which will therefore be the first non * character. The FIND function then looks for that character in the original string and MID returns everything from that point onwards. Does that help?
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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