I have an Excel sheet with data only in the first column, where each cell starts with the character H, G, I, B, H, E, S, C, or none of the above.
I would like to write a command so that in the second column, one of four things will happen:
If the cell in the first column starts with H, G, or I, then the cell in the second column is assigned H
If the cell in the first column starts with B or E, then the cell in the second column is assigned E
If the cell in the first column starts with T, S, or C, then the cell in the second column is assigned C
If the cell in the first column starts with none of the above, then the cell in the second column remains blank
I found that this command does part of the problem:
=IF(OR(B25="H"; B25="G"; B25="I");"H";"") & IF(OR(B25="B"; B25="E");"E";"") & IF(OR(B25="T"; B25="S"; B25="C");"C";"")
However, this only works if the first column only contains one character. I would like to tailor this command so that it does not require there to only be one character in the first column, but that it simply starts with the character.
I hope this makes sense. Please let me know if you have any advice!! :O)
Maybe the "LEFT()"-Function is what you are looking for.
Something like "LEFT(A1,1)" should give you the first Character of the String in Cell A1.
More information:
http://office.microsoft.com/en-us/excel-help/left-leftb-functions-HP005209153.aspx
EDIT: Wow, this community is always impressing me. (Too fast for me ;))
Create a small table elsewhere in in the workbook. Let's give it the named range "MyLookup" for the sake of example. This table simply maps the input values to the desired output values, like so:
MyLookup:
Input Output
H H
G H
I H
B E
E E
etc...
Now use this very simple formula to get your result:
=IFERROR(VLOOKUP(LEFT(B25,1),MyLookup,2,FALSE),"")
Make sense?
try this:
=IF(OR(LEFT(AB25,1)="H"; LEFT(AB25,1)="G"; LEFT(AB25,1)="I");"H";"") & IF(OR(LEFT(AB25,1)="B"; LEFT(AB25,1)="E");"E";"") & IF(OR(LEFT(AB25,1)="T"; LEFT(AB25,1)="S"; LEFT(AB25,1)="C");"C";"")
Related
This is a bit tricky to explain, so I'll try my best:
This is dummy data but it's good to explain my question.
I have some columns called A, B, C and D and a Check one.
What I did in column I, as you can see in the formula, is count everytime when Check is 0 AND each column A,B,C and D take the value in B1, which is a drop down list with Y, N and * (to grab all possible occurrences). As you can see in I5, in Column A there is only 1 occurrence that had check = 0 and it's value in A is N.
I was thinking it would be good to, instead of having a cell for the Count for each column, creating a second drop down list to select what column I'm interested in. I created this drop down list on B13.
As I hardcoded in this snippet, in this case when Outcomes = N and Column = A, the Generic count should be 1.
How can I do this? I've tried LOOKUP, MATCH, INDIRECT, ADDRESS, INDEX, etc, but couldn't make it work. Haven't found any tutorial that helps.
Use:
=COUNTIFS(INDEX($B$4:$E$11,0,MATCH($B$13,$B$3:$E$3,0)),$B$1,$F$4:$F$11,0)
Alternatively, maybe something along the lines of:
=SUMPRODUCT((B3:E3=B13)*(ISNUMBER(SEARCH(B1,B4:E11)))*(F4:F11=0))
I am trying to find a value in a excel column which corresponds with the first empty value from another column and down one. So if D is the empty row then I want G
For example
A B C
D E
G H I
J K L
Would print G since the third column is where we are searching for the first null which is at line 2.
I tried =MIN(IF(A1:A4="", ROW(A1:C4))) which gets the right row but when I enter it in an index function it just gets me A if there is a null in the column.
I Have also tried =IFERROR(INDEX(A1:A4,1/MAX(INDEX((LEN(A1:D4)=0)/ROW(A1:D4),))),"No null")
Which worked but didn't work if you have multiple empty cells in a column
Based on the clarification that the OP wants the subsequent row returned (not the one with the empty cell), another way to derive what QHarr showed but without the use of an array formula would be something like this:
=INDIRECT("A"&INDEX(MAX((C1:C4="")*ROW(C1:C4))+1,1))
or
=INDEX(A1:A4,INDEX(MAX((C1:C4="")*ROW(C1:C4))+1,1))
If you don't know the last row, you could replace the ranges with a formula that determines the last row of data using an indirect cell reference like this:
=INDIRECT("A"&INDEX(MAX((INDIRECT("C1:C"&INDEX(MAX((A:A<>"")*(ROW(A:A))),1))="")*ROW(INDIRECT("C1:C"&INDEX(MAX((A:A<>"")*(ROW(A:A))),1))))+1,1))
or
=INDEX(INDIRECT("A1:A"&INDEX(MAX((A:A<>"")*(ROW(A:A))),1)),INDEX(MAX((INDIRECT("C1:C"&INDEX(MAX((A:A<>"")*(ROW(A:A))),1))="")*ROW(INDIRECT("C1:C"&INDEX(MAX((A:A<>"")*(ROW(A:A))),1))))+1,1))
I hope this helps.
I am still not sure that we are answering the correct question.
My understanding is that =MIN(IF(A1:A4="", ROW(A1:C4))) which you indicate returns the correct row doesn't do anything like what I thought you were asking for. I am not sure that I understand what you were trying to achieve.
Likewise, when I use:
=IFERROR(INDEX(A1:A4,1/MAX(INDEX((LEN(A1:D4)=0)/ROW(A1:D4),))),"No null")
I get "A"
Are you looking for the first column of the row after the row with a blank in the third column or are you looking for the first column of a row with any empty cell (including the first one) or something else?
I would do the following array formula:
=INDEX(A1:A4,MIN(IF(C1:C4="",ROW(C1:C4)))+1)
Entered with Ctrl + Shift + Enter
Data:
Good Morning,
I was wondering if there was a way to place a formula in Column F:
If respective E Cell starts with AI, extract the first three
characters in the F cell.
If respective E Cell starts with anything else, extract only the first two characters in the F Cell.
example of desired output
Any help you can provide will be very helpful!
You should always check that the string is long enough before extracting portions:
=IF(LEN(A1)>2, LEFT(A1,2+N(LEFT(A1,2)="Al")),"too short")
If cell starts with "AI" show first 3 chars of E Cell otherwise 2
=LEFT(E1, IF(LEFT(E1,2) = "AI",3,2))
I have the following data
Person Week1
P1 L,L
P2 M,H
Output I would like is
Person Week1
L M H
P1 2 0 0
P2 0 1 1
My intention is to create a chart based on the output so I can figure out how many codes a person got per week. Pivot tables does not seem to work for this case.
Thanks
This is a pure formula approach.
Its based off of two basic formulas. The first formula is how to count the number of times a string A occurs within string B. This is done, by counting the number of characters in the string B, then by counting the number of characters in String B after string A has been replaced by nothing or "". If string A is more than 1 character long you need to divide the result by the length of string A. That gives us this formula:
=(LEN(STRING B)-LEN(SUBSTITUTE(STRING B, STRING A, "")))/LEN(STRING A)
Now we know how to count the number of time L, M or H occur as they are string A and now we need to determine string B.
IF we look at the first table, it has nice row headers and column hearders. We could take a short cut and just assume everything is in order however I am going to go with the more generic approach in case the headers happen to be in a random order.
Basically we need to find out what column in the first table matches with the header in our second table. ie is week2 really the second column? is P1 still the first row? in order to do that we use the following
=MATCH("WEEK X",$B$1:$D$1,0)
and
=MATCH("PX",$A$2:$A$3,0)
Those will return an integers which we can then drop into the an INDEX function to locate and find the text in the first table:
=INDEX($B$2:$D$3,MATCH("PX",$A$2:$A$3,0),MATCH("WEEK X",$B$1:$D$1,0))
AWESOME we now know how to find the text from the table to drop into our counting formula that we started with. That las formula gets substituted into wherever there is STRING B!
=(LEN(INDEX($B$2:$D$3,MATCH("PX",$A$2:$A$3,0),MATCH("WEEK X",$B$1:$D$1,0)))-LEN(SUBSTITUTE(INDEX($B$2:$D$3,MATCH("PX",$A$2:$A$3,0),MATCH("WEEK X",$B$1:$D$1,0)), STRING A, "")))/LEN(STRING A)
yeah its getting a little ugly isn't it! String A is then whatever cell L is in in your second table. Replace "Week X" with your week header in your second table. Replace "PX" with the name of your person in your second table.
I would do the first formula, then copy it over under the M and under the H. Go into the M and H formula and adjust it so its pointing at the right week header in each. Lock the row but not the column references for the week header and the string A cells. Lock the column but not the row for the persons name. once you have that set up, copy al three formulas and paste under each week. Then just copy your entire first row of table two down for the number of people you have and voila!
Proof of concept
The formula I used in Cells H3, I3, and K3 respectively
=(LEN(INDEX($B$2:$D$3,MATCH($G3,$A$2:$A$3,0),MATCH(H$1,$B$1:$D$1,0)))-LEN(SUBSTITUTE(INDEX($B$2:$D$3,MATCH($G3,$A$2:$A$3,0),MATCH(H$1,$B$1:$D$1,0)),H$2,"")))/LEN(H$2)
=(LEN(INDEX($B$2:$D$3,MATCH($G3,$A$2:$A$3,0),MATCH(H$1,$B$1:$D$1,0)))-LEN(SUBSTITUTE(INDEX($B$2:$D$3,MATCH($G3,$A$2:$A$3,0),MATCH(H$1,$B$1:$D$1,0)),I$2,"")))/LEN(I$2)
=(LEN(INDEX($B$2:$D$3,MATCH($G3,$A$2:$A$3,0),MATCH(H$1,$B$1:$D$1,0)))-LEN(SUBSTITUTE(INDEX($B$2:$D$3,MATCH($G3,$A$2:$A$3,0),MATCH(H$1,$B$1:$D$1,0)),J$2,"")))/LEN(J$2)
Here is another proof of concept with expanded range showing rows out of order, and multiple letter strings to be searching for and more than two entries. Same formulas, just had to adjust the look up ranges for the increased table size.
If using VBA is acceptable, splitting the comma separated data using TextToColumns should help as a first processing step.
Then using a pivot table gives you the output you want.
I have a large table in excel that has column headings A, B, C, D, and ANSWER
A, B, C, D represent the multiple choice questions I have in the table.
I also have an ANSWER column that has the answers represented by the corresponding multiple choice heading letter mentioned above.
For example, under each column heading (A, B, C, D), I have the possible answers, Food, Car, House, School.
In the example above, House (C) is the correct answer. I would like to create an IF statement that matches the Answer cell, which has C in it with the A, B, C, D column headings and if there's a match, then insert an = before the actual answer. In this case, the result would be =house. The rest of the answers should have the ~ inserted before the word, i.e., ~food, ~car, ~school.
The final result should look like this: ~food, ~car, =house, ~school.
The only way to achieve that securely is to duplicate the table in another sheet or in different columns.
Why is that?
Because you want to change the SOURCE of your statement. Excel would consider that a circular reference and couldn't resolve it.
There's a VBA code solution, that you can run ONLY ONCE. That would change the source data as well and you would lose your originals. Could be an action with no turning back.
So:
I suggest you create a new sheet, put the headers A, B, C and D.
So you would have two sheets: the OriginalSheet containing the answers and each option.
And the ResultSheet, containing the options formated as you want.
In the ResultSheet, use this formula:
= IF(OriginalSheet!$E2 = A$1; "="; "~") & OriginalSheet!A2
That is considering the first line containig the texts: A, B, C and D. So you must insert this formula in the A2 cell of the ResultSheet.
You can click in the little black square in bottom right of the cell and drag this formula to all other cells. (The $ simbols garantee the drag will be safe)