Find the first character in a cell

Mindpsyche

Well-known Member
Joined
Mar 19, 2012
Messages
760
Hello,

If I have a cell which begins with a few spaces and then has a character, how do I use the find function to see how many spaces until some character is present in the cell. The * does not work with this.

Excel 2007
B
4 a

<colgroup><col style="width: 25pxpx"><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,701
Office Version
  1. 365
Platform
  1. Windows
Not sure if this is what you want, but you can try, the following which works without using the FIND function:
Code:
=LEN(A1)-TRIM(LEN(A1))
This will count the number of spaces at the start until a non-space character is reached
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,201
Hello,

If I have a cell which begins with a few spaces and then has a character, how do I use the find function to see how many spaces until some character is present in the cell. The * does not work with this.

Excel 2007
B
4 a

<tbody>
</tbody>
Sheet1

=FIND(LEFT(TRIM(B2),1),B2)

returns the position of the non-space char.

=FIND(LEFT(TRIM(B2),1),B2)-1

gives the number of spaces to the first non-space char.
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,201

ADVERTISEMENT

Not sure if this is what you want, but you can try, the following which works without using the FIND function:
Code:
=LEN(A1)-TRIM(LEN(A1))
This will count the number of spaces at the start until a non-space character is reached

Trailing and extraneous in-between spaces would thwart this formula completely.
 

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,701
Office Version
  1. 365
Platform
  1. Windows
Thanks Aladin, wasn't aware of that
 

Watch MrExcel Video

Forum statistics

Threads
1,123,334
Messages
5,601,012
Members
414,421
Latest member
tonybear1994

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