The program exporting to Excel creates an indented file in one column:
Column A First Text Second Text Third Text Fourth Text Fifth Text
How to create a function in excel that counts the number of spaces before a line of text?
So, to return: 1 for the first text line and 3 for the line for thirst, etc. in this example.
It is advisable to look for a solution other than VBA.
TRIM doesn't help here, as it removes double spaces between words.
TRIM
The main idea is to find the FIRST letter in the trimmed line and find its position in the original line:
=FIND(LEFT(TRIM(A1),1),A1)-1
Try the following:
=FIND(" ",A1,1)-1
1, .
Ms Excel:
=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))
, . /, .
http://www.mrexcel.com/forum/excel-questions/61485-counting-spaces.html :
=LEN(Cell)-LEN(SUBSTITUTE(Cell," ",""))
Cell - ( A1, B1, D3 ..).
:
B8: =LEN(F8)-LEN(SUBSTITUTE(F8," ","")) F8: [ this is a test ] produces 4 in B8.
, , . , . , , 6.
, TRIM SUBSTITUTE, .
SUBSTITUTE
=MATCH(TRUE,MID(A1,COLUMN($A$1:$J$1),1)<>" ",0)-1
, .. Ctrl - Shift - Enter Enter.
10 , $J !
$J
. 5 "_____" (5 ), 5, 4 ..
=IF(LEFT(B1,5)=" ",5,IF(LEFT(B1,4)=" ",4,IF(LEFT(B1,3)=" ",3,IF(LEFT(B1,2)=" ",2,1))))
LEN + TRIM , :
=LEN(Cell)-LEN(TRIM(Cell))
Source: https://habr.com/ru/post/1527668/More articles:Python - how can I use generators more succinctly? - pythonOpenCV C ++: How to slow down background mapping of BackgroundSubtractorMOG? - c ++Open port 443 by adding a rule to iptables (Ubuntu) - linuxConcurrency management in entity structure - c #Chef loading problems - chefClip plays wav file with bad delay in java - javawhy does jsp launch PropertyNotFound? - syntaxHow to add a custom paragraph style to my SharePoint 2013 blog? - cssHow to get img by css jQuery property - jqueryКак вручную класть узлы на поиск elastics - elasticsearchAll Articles