Text position within cell

Kamran01

Board Regular
Joined
Feb 10, 2017
Messages
86
Dear All,

Please help me to know, how can i find text position within cells.

Sentence is, "Election commission has organized the Election 2018."

There are two "Election" and want to know both locations separately suppose first election location is 1 and second "Election" location is 38.

Thanks in advance,

Best Regard,
Kamran Noor
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
with
C1 = "Election"
D1 = "Election commission has organized the Election 2018"

=SEARCH("find this", "search this text", start at this position)

FIRST
=SEARCH(C1,D1,1)
SECOND
=SEARCH(C1,D1,SEARCH(C1,D1,1)+LEN(C1))
THIRD
=SEARCH(C1,D1,SEARCH(C1,D1,SEARCH(C1,D1,1)+LEN(C1))+LEN(C1))
etc

Start position is the previous found position + number of characters in search string
 
Last edited:
Upvote 0
or
1st: =IFERROR(SEARCH("Election",A1,1),"")
2nd: =IFERROR(SEARCH("Election",A1,2),"")
3rd: =IFERROR(SEARCH("Election",A1,SEARCH("Election",A1,2)+1)-1,"")
 
Last edited:
Upvote 0
Dear Yongle,

Thank you for these but if i want to know how many election in this sentence than?

I used this function and got answer, but don't know how to check counts of this sentence in the cell.

=SEARCH(A8,A4,SEARCH(A8,A4,SEARCH(A8,A4)+1)+1)
 
Last edited:
Upvote 0
For the original question, try this formula copied across and down to get all the positions.

Note that if you are looking for the "word" election, the earlier formula suggestions fail for the sample text in my row 3 below because the text "election" is contained within the word "selection"

Excel Workbook
ABCDEF
1Election commission has organized the Election 2018139
2The election in 1998 was the closest election since the election of 1977 although the election of 1994 was also close5385787
3The selection of the election date is done by the electoral commission22
Positions (2)
 
Last edited:
Upvote 0
That's right Peter

If OP want to count Election in whole column (eg. table in post#6) PowerQuery can be used. It will count all (separated) Election in this column (count: 7)

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table9"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1", type text}}),
    #"Uppercased Text" = Table.TransformColumns(#"Changed Type1",{{"Column1", Text.Upper, type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Uppercased Text", each ([Column1] = "ELECTION")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Column1"}, {{"Count", each Table.RowCount(_), type number}})
in
    #"Grouped Rows"[/SIZE]
 
Last edited:
Upvote 0
If OP want to count Election in whole column (eg. table in post#6) PowerQuery can be used.
I haven't seen that request in this thread, but if it was required, I'd still use the much shorter & simpler to implement (to me anyway) standard worksheet formula

=SUMPRODUCT(LEN(" "&A1:A3&" ")-LEN(SUBSTITUTE(UPPER(" "&A1:A3&" ")," ELECTION ","")))/10
 
Upvote 0
I haven't seen that request in this thread, but if it was required, I'd still use the much shorter & simpler to implement (to me anyway) standard worksheet formula

Sure, but we've different point of view what is simpler :)

btw. column can contain 1 row also

All is good what works good :cool:
 
Last edited:
Upvote 0
Thank you for these but if i want to know how many election in this sentence than?
To deal with upper/lower case issues and to ensure whole words as mentioned in post 6, I would use this version to count in a sentence.

Excel Workbook
AB
1Election commission has organized the Election 20182
2The election in 1998 was the closest election since the election of 1977 although the election of 1994 was also close4
3The selection of the election date is done by the electoral commission1
Positions (3)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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