How to Extract numbers from text to a column - excel

I am new here and I have an Excel 2013 question.
How to extract numbers from one specific character to a column?
The strings are like: A10 B203 A22 K34 A60 A92 A81 A2 and
I would like to extract numbers after character A in one column
So, the result should be 10,22,60,92,81,2.
Max repetitions of A is 6. If is possible a Formula for this

If you want a formula to get rid of the first character and your list is in column A, enter this in B1:
=IF(LEFT(A1,1)="A",RIGHT(A1,LEN(A1)-1),"")

I'd suggest VBA, but since you have asked for a formula:
Apply Text to Columns with space as delimiter. If starting in A1 should populate A1:H1.
In J1 and copied across to Q1 (and down as desired):
=IF(LEFT(A1)="A",A1,"£")
(Use # or | or whatever suits if £ does not.)
Select ColumnsJ:Q Copy and Paste Special..., Values over the top.
Select ColumnsJ:Q and replace A by nothing, then £ by nothing.
Select ColumnsJ:Q and Go To Special..., Blanks click on one of those selected and Delete... with Shift cells left.
In S1 (copied down if required):
=LEFT(J1&","&K1&","&L1&","&M1&","&N1&","&O1&","&P1&","&Q1,
LEN(J1&","&K1&","&L1&","&M1&","&N1&","&O1&","&P1&","&Q1)-8+COUNT(J1:Q1))
(Beware of a line break if copying the above.)
(TEXTJOIN would be nice but is not available in all Excel versions.)
Should accommodate fewer than eight entries in a 'set' but would need adjustment for more than that.

Related

Using IF and conditional formatting

I'm trying to have a cell becoming highlighted if it satisfies two criteria.
I would like the cells below each Staff column to be purple if its both the same as the version# and contains *.
I've managed to highlight cells containing the * by using "highlight if cells contain" ~* but I can't get it to do both.
I've tried
=AND(L2=$J2,"~*")
=AND($J2,"~*")
=IF(AND(L2=$J2,"~*"))
(Version# is column J, Staff 1 is column L)
Answer by BigBen
If the Staff # contains an asterisk, will it always immediately follow the version #? If so you could just do
=L2=$J2&"*"
Seeing what I think you want, the main issue is the asterisk. When you enter a number in a cell and also enter a non-numerical character the cell automatically becomes formatted as TEXT. It is possible to extract the numerical value with a formula, but handling what you want is much easier if you separate the number from the asterisk. In my included example (You should be able to open it in a new tab on your browser) created narrow columns after each 'staff#' column to accept the asterisk entry.
This done, enter the three conditional formats as shown (in C2 in the example). You then copy the C2 cell into each of the cells under the Staff# columns. That produced the results shown which I think is what you want. Changing entries will produce the proper formatting results for that cell.

Issue with Formulas not showing data after Row insert

Hi I have 2 sheets in Excel. One sheet, called DATA, has questions such as :"How did you find the room" with answers like "Excellent".
On the 2nd sheet I have a formula
=IF(Data!$I$4="Excellent ",5,IF(Data!$I$4="Good",4,0))
I have copied this formula to row 10.
If I add extra rows to the DATA sheet, the formulas in the 2nd sheet do not appear.
You are using absolute reference. Try removing the $. When the $ is present it prevents the row or column number from changing as the formula is copied. Place the cursor in a cell reference or select a range reference and press F4 repeatedly and it will cycle through the $A$1, A$1, $A1, A1 options.
Also note you have a space after "Excellent ". Matching for "Excellent" is not the same as "Excellent ". You may want to change your formula to:
=IF(Trim(Data!$I$4)="Excellent",5,IF(Trim(Data!$I$4)="Good",4,0))
Trim will remove excess spaces between words and only leave 1 space in between.
If you have more than just excellent in the cell and maybe something like "Excellent Job", you might want to use the SEARCH or FIND functions in your formula.

Average of top 10 values in a row, treating empty cells as ones

Suppose I have a row in excel consisting of n cells (in fact n=12). Some of these cells have numerical values, some may be empty. I want to find the average of the top m cells in the row (in fact m=10), treating the empty cells as if they contained 1s.
(The context for this is that I want to compute the average grades of some students whose homework I grade, and this is the formula used in the course. The empty cells correspond to homeworks which were not handed in, but I would like to keep the distinction between homeworks graded 1 and those missing.)
Based on data in A1:L1, array formula**:
=AVERAGE(LARGE(IF(ISNUMBER(A1:L1),A1:L1,1),{1,2,3,4,5,6,7,8,9,10}))
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
Put the 12 items in cells B1 thru M1. In B2 enter:
=IF(B1="",1,B1)
and copy across. In A1 enter:
=LARGE($B$2:$M$2,ROWS($1:1))
and copy down. Now to get the average of the top 4 grades, simply pick a cell and use:
=AVERAGE(A1:A4)
To get the top 5, use =AVERAGE(A1:A5), etc.
Well, it can be done slightly less complicated than arrays, by just splitting the average into its parts, the sum and the division.
=(sum(B2:K2)+countif(B2:K2,0))/10
This is for scores horizontally starting in the B2 row. You sum the scores, then count the zeroes (which is what you want to add to the sum). Then divide by m.

Is it possible to specify some value/text in a specific number of column cells depending on the input of another cell?

If I have a cell in which the input has to be a number, is it possible to insert some specific text in a number of consecutive columned cells somewhere else in the sheet.
I'm not sure whether this is done with a formula or another built in function.
As an example, say I have a cell E4.
If I enter the number 3 in E4, the cells F1,F2,F3 show some text. If I change the number in E4 to 6 then cells F1-F6 now display some text.
Is this at all remotely possible?
I know I would be able to to do this with multiple IF-THEN-ELSE, but is there a more efficient method?
I'll presume you are in a google-spreeadsheet and not in an excel (your tags are confusing btw)
I would do that using a hidden cell to minimize the numbers of IF statements.
Saying E4 is your numeric cell, put only one IF in F4 like
IF(E4=1;"text text2";IF(E4=2;"othertext othertext2 othertex3"; IFS... ))
So you will have the whole texts in a unique cell (I separated then by spaces but if you have spaces in your text just use a more convenient character).
Then you can do a SPLIT on G4 like
=SPLIT(F4;" ")
(or split on the character you have used).
And it will separate your data in 1, 2, 6, or how many rows you'll need for your data without having to make if statements for each row.

search multiple columns for a value and concatenate the address of the cells

I have been breaking my head over this formula for sometime now. I have found a solution which is too big and not so convenient to use every time. So can any Excel Expert give me a solution/suggestion?
Column A contains 150 values. Column D to R contains a table in which I need to look up the values in A one by one. I want to return address of all the cells that contains the value.
For example, Value in A2 is present in cells D5, E15, H10, R3 then my result should be D5,E15,H10,R13.
Please Note that some columns may not contain the value of A2, I do not want them displayed.
Here is the formula I have written:
=CONCATENATE(
IF(A2=IF(COUNTIF(D:D,A2),VLOOKUP(A2,D:D,1,FALSE),""),ADDRESS(MATCH(A2,D:D,0),4,4),0),",",
IF(A2=IF(COUNTIF(E:E,A2),VLOOKUP(A2,E:E,1,FALSE),""),ADDRESS(MATCH(A2,E:E,0),5,4),0),",",
IF(A2=IF(COUNTIF(F:F,A2),VLOOKUP(A2,F:F,1,FALSE),""),ADDRESS(MATCH(A2,F:F,0),6,4),0),",",
IF(A2=IF(COUNTIF(G:G,A2),VLOOKUP(A2,G:G,1,FALSE),""),ADDRESS(MATCH(A2,G:G,0),7,4),0),",",
IF(A2=IF(COUNTIF(H:H,A2),VLOOKUP(A2,H:H,1,FALSE),""),ADDRESS(MATCH(A2,H:H,0),8,4),0),",",
IF(A2=IF(COUNTIF(I:I,A2),VLOOKUP(A2,I:I,1,FALSE),""),ADDRESS(MATCH(A2,I:I,0),9,4),0),",",
IF(A2=IF(COUNTIF(J:J,A2),VLOOKUP(A2,J:J,1,FALSE),""),ADDRESS(MATCH(A2,J:J,0),10,4),0),",",
IF(A2=IF(COUNTIF(K:K,A2),VLOOKUP(A2,K:K,1,FALSE),""),ADDRESS(MATCH(A2,K:K,0),11,4),0),",",
IF(A2=IF(COUNTIF(L:L,A2),VLOOKUP(A2,L:L,1,FALSE),""),ADDRESS(MATCH(A2,L:L,0),12,4),0),",",
IF(A2=IF(COUNTIF(M:M,A2),VLOOKUP(A2,M:M,1,FALSE),""),ADDRESS(MATCH(A2,M:M,0),13,4),0),",",
IF(A2=IF(COUNTIF(N:N,A2),VLOOKUP(A2,N:N,1,FALSE),""),ADDRESS(MATCH(A2,N:N,0),14,4),0),",",
IF(A2=IF(COUNTIF(O:O,A2),VLOOKUP(A2,O:O,1,FALSE),""),ADDRESS(MATCH(A2,O:O,0),15,4),0),",",
IF(A2=IF(COUNTIF(P:P,A2),VLOOKUP(A2,P:P,1,FALSE),""),ADDRESS(MATCH(A2,P:P,0),16,4),0),",",
IF(A2=IF(COUNTIF(Q:Q,A2),VLOOKUP(A2,Q:Q,1,FALSE),""),ADDRESS(MATCH(A2,Q:Q,0),17,4),0),",",
IF(A2=IF(COUNTIF(R:R,A2),VLOOKUP(A2,R:R,1,FALSE),""),ADDRESS(MATCH(A2,R:R,0),18,4),0))
As I said, this works but I am looking for a simpler and smaller formula.
Hint: Maybe using array can help?
Thanks in advance :)
What you are trying to accomplish is not a great fit for Excel formulas, but it can be done with a smaller, simpler formula dragged across 15 columns instead of 1 giant complicated formula that tries to do everything at once.
Assuming column A has 150 values (from A1 to A150), and there is a table going from D1 to R50...
Enter =S1&IFERROR(","&ADDRESS(MATCH($A1,D$1:D$50,0),COLUMN(D1)),"") into T1.
Drag the formula across to AH1.
Enter =RIGHT(AH1,LEN(AH1)-1) into AI1.
Select T1 to AI150 and press Ctrl-D.
Column AI1 will contain the results you are looking for.
How does this work?
The formula in T1 begins by taking the result of one cell to the left (which is blank). Then it concatenates this with the address of the first match in column D (prefixed by a comma). If there is no match, it just concatenates blank (""). As you drag this formula to the right, it keeps concatenating addresses as matches come up (or blank if there are none). When you get to the end, you will have looked for matches in all 15 column of your table.
The formula in AI1 just strips off the initial comma if there is one.

Resources