Counting lines of text after a specific word - excel-formula

I need to find out how many lines a character has in a play using Excel. The entire play is copied into one column in excel and I need to find out how many spoken lines a specific character has. When a character speaks, their name is listed in bold and all caps, followed by a blank cell then all of the lines they are speaking until another character speaks. At the end of their lines is another blank cell. So for example it would look like this:
1st CHARACTER
(Blank Cell)
"Line"
"Line"
"Line"
(Blank Cell)
2nd CHARACTER
I need a formula to count how many lines occur for the first character, but one that can be repeated for the entire play. Any ideas even if its just a preliminary formula would be greatly appreciated.
I have tried using COUNTIF, OFFSET, INDEX/MATCH and I just can not find the right combination to get the correct output and then apply that to the whole play.

Count lines of text after a specific word/character
Assume data housed in Column A with criteria in Column C
In D2, formula copied down :
=SUM(AGGREGATE(15,6,ROW(INDEX($A$1:$A$100,MATCH(C2,$A$1:$A$100,0)):$A$100)/(INDEX($A$1:$A$100,MATCH(C2,$A$1:$A$100,0)):$A$100=""),{1,2})*{-1,1})-1

Related

Can I change just the cell reference letter rather than all of that letter within a formula for the entire column

I have made an error when copying formulas across multiple columns and need to correct them. The issue is I have multiple breaks in the rows so I can't just drag the formula down for each column.
If I use search and replace to change the letter, it also replaces all other letters within the formula.
Is there a way to just change the cell reference letter?
Example:
=VLOOKUP(C10,CAT!A:C,3,FALSE)
If I find and replace C, as I need to change it to D10, I end up with =VLOOKUP(D10,DAT!A:D,3,FALSE) but need to end up with =VLOOKUP(D10,CAT!A:C,3,FALSE)
Any help would be very much appreciated as it is a very large spreadsheet and I am dreading doing it manually.
Cheers

How to make visible only last 3 characters from Excel cell

I have a row that contains different numbers. first 5 characters from each cell are equal, difference is only in last 3 characters (Example: 10265083, 10265154, 10265360).
I don't need to make the cell so wide as length of the number, because the sheet will be too large visually. So I need to see only last 3 characters in cell. In formula bar should be the whole number, because I need to use full number for further formulas.
Is it possible to do something like this?
I tried all kinds of cell formatting, I didn't find any way only to show the last three digits. Therefore I opt for another approach: just create a helper column, containing the following formula: =MOD(J7,1000).

Regex replace and split using Google SHeets formula

I have a sheet where I need to split the numbers and text on single cell to 2 columns
https://docs.google.com/spreadsheets/d/1ZaQmWCx2PH6Fhn3RVW9PKpnTv0ML9zAHWzmk3789b04/copy
Please note the data is in single cell and I need to split in 2 columns as shown in the image
The expected outout is
I have tried with =REGEXREPLACE(A796,"[0-9]","")
You may use 2 formula in 2 different cells for this:
Formula #1:
=REGEXREPLACE(A4,"[[:blank:]].*","")
This finds first space and removes everything after that so that we have only starting numbers left in the result.
Formula #1:
=REGEXREPLACE(A4,"[0-9]+[[:blank:]]+","")
This matches starting 1+ digits followed by 1+ whitespace and removes it so that we only have text after starting numbers.
Sheet Demo
You can also try- B2
=TEXTJOIN(CHAR(10),False,INDEX(ArrayFormula(SPLIT(SUBSTITUTE(TRANSPOSE(SPLIT(A2,CHAR(10)))," ","#",1),"#")),,1))
C2=
=TEXTJOIN(CHAR(10),False,INDEX(ArrayFormula(SPLIT(SUBSTITUTE(TRANSPOSE(SPLIT(A2,CHAR(10)))," ","#",1),"#")),,2))

Advance search to find duplicate records in Excel

I want to find similar data in Excel cell based on characters for example in one column I have ABCDEF and another column I have DEAFBC, so in this case both cell contains characters abcdef, any solution to match?
I tried like, similar, partial match options in Excel which didn't meet my results.
Separate each letter into it's own cell (text to columns, fixed width). Copy to a new column first if you want to keep the original data.
Sort each row (this is a little tricky, but it is possible - see my example.)
Combine the cells again by just stitching them together using &.
You can now sort to easily see duplicates or remove them etc.
The formula to paste into cell I2 in my example is:
=INDEX($B2:$G2, MIN(IF(SMALL(COUNTIF($B2:$G2, "<"&$B2:$G2), COLUMNS($H2:H2))=COUNTIF($B2:$G2, "<"&$B2:$G2), ROW($B2:$G2)-MIN(ROW($B2:$G2))+1)), MATCH(SMALL(COUNTIF($B2:$G2, "<"&$B2:$G2), COLUMNS($H2:H2)), COUNTIF($B2:$G2, "<"&INDEX($B2:$G2, MIN(IF(SMALL(COUNTIF($B2:$G2,"<"&$B2:$G2),COLUMNS($H2:H2))=COUNTIF($B2:$G2,"<"&$B2:$G2), ROW($B2:$G2)-MIN(ROW($B2:$G2))+1)), , 1)), 0), 1)
Make sure you hit Ctrl+Enter when exiting the cell, since this is an array formula.

Search for text within a range of cells in Excel using an IF statement

I need to search for text within a range/array of cells in Excel.
Right now I have a working formula to search for 2 non-printing characters in a single cell, but I need to search multiple cells on the same row.
What is working: =IF(NOT(ISERROR(SEARCH(" ",$H2))),"Non-printing character",IF(NOT(ISERROR(SEARCH(" ",$H2))),"Non-printing character","OK"))
What I want to do is search $H2:$Q2 and if a non-printing character is contained anywhere within $H2:$Q2, I want cell G2 to display "Non-printing character." If a non-printing character is not found, I want G2 to display "OK."
Any ideas?
This is an extension of your posted formula to test multiple cells:
=IF(NOT(ISERROR(SEARCH(" ",TEXTJOIN("",TRUE,H2:Q2)))),"Non-printing character",IF(NOT(ISERROR(SEARCH(" ",TEXTJOIN("",TRUE,H2:Q2)))),"Non-printing character","OK"))
We replaced:
$H2
with:
TEXTJOIN("",TRUE,H2:Q2)
Since I don't need to nest, and I just need to find one non-printing character within a range, I was able to use the following formula:
=IF(NOT(ISERROR(SEARCH(" ",CONCATENATE($H2,$I2,$J2,$K2,$L2,$M2,$N2,$O2,$P2,$Q2)))),"Non-printing character","OK")

Resources