Finding any occourrence of a character in a string

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
3,448
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hi everybody,
in a string like "Dear friends please I need your help" how can I get the position of the first, the second, the third and so on position of a specific character, for example the "space"?
Now I do that via Udf, but I should do the job without using vba, if possible.

Thanks for your help.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,892
Hi

Assuming the string in A1, in B1:

=FIND("#",SUBSTITUTE($A1," ","#",COLUMNS($B1:B1)))

Copy to the right. It will give you the positions of the spaces in the string.
 
Upvote 0

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
3,448
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Many thanks to both of you for your answers.
pgc01's formula does perfectly the job, ie the possibility of finding not only the first occourrence of the character but also the second, third and so on.

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,191,120
Messages
5,984,762
Members
439,909
Latest member
daigoku

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
Top