Formula to replace values If cell is not empty (e.g."Y" for yes) to be replaced by an absolute reference cell? - excel-formula

This may be simple - I am using a costing sheet that has been built to be somewhat of a checklist, in a row of names. I want to be able to tick or use text "Y" (Yes) if costings should be added to a person in the same cell the text was entered.
Example:
J$10 refers to a cost, I want this reference to replace entered text in a cell without having to manually click to replace certain values. In short - replacing specified text with another cell with an absolute reference of its own($).
Formula for:
IF "Y" is entered replace to J$10
at the moment I am manually pasting "J$10" (refers to a standard costing sum) next to a row of candidate names but this has a lot of columns per name under predetermined costs selections.

What Max R is hinting at: use another column for this.
J$10 holds a sum, if you were to use column K for the "Y" value, then your formula in column L would need to be:
=if(K10 = "Y", J$10, 0)
assuming you want to sum all with a "Y": you can do this on column L

Related

Is there an alternative for the Excel function CONCATENATE that doesn't require text?

In excel, I am trying to obtain the average of a range of numbers in a single column with a fixed start row (B4) and a variable end row (which is the value of Cell C2 minus 1 with the match function) I am using the following formula in Excel that works perfectly:
=AVERAGE(B4:INDIRECT(CONCATENATE("B",MATCH((C2-1),A:A,0))))
HOWEVER, I will need to copy and paste this formula into other columns, so the "B" will need to change to a "G" and so on. The new column letter will always be +5 from the previous column, and -3 from the column the cell formula is stored in. I want Excel to auto-populate the change in column letter, but CONCATENATE only works with text. I tried to use the offset function in place of the CONCATENATE "B" argument (see below), but I think INDIRECT might require text as well and/or I'm using the offset function incorrectly.
AVERAGE(B4:INDIRECT((OFFSET(5,-3,0)) & MATCH((C2-1),A:A,0))))
Does anyone have any ideas for a fix?
Use INDEX:
=AVERAGE(B4:INDEX(B:B,MATCH((C2-1),A:A,0)))

How can I keep the same cell reference in if function, until the if function is true/false?

I have the following function in excel:
INDIRECT(CHAR(COLUMN()+53)&O1+1)
This function has to be the outcome of an if-statement when the statement is true. I don't want the O1 to change to O2, O3, etc.. when I drag the function down, until the statement is true. From there I want the function to change this cell reference in ascending order. So as long as the if statement is false, the reference needs to be O1.
I know that absolute referencing can be used to keep the same cell-reference ($O$1), but then the cell reference doesn't change when the statement is true either.
My data looks like this: enter image description here
My complete formula looks like this: enter image description here
=IF(P2=INDIRECT(CHAR(COLUMN()+51)&O1+1);IF(INDIRECT(CHAR(COLUMN()+51)&O2+1)="";INDIRECT(CHAR(COLUMN()+53)&O1+1);INDIRECT(CHAR(COLUMN()+51)&O2+1));IF(INDIRECT(CHAR(COLUMN()+53)&O2+1)="";"";INDIRECT(CHAR(COLUMN()+51)&O2+1)))
What I want to do is to fill a column with values of the first column in the data until the cells are empty. Then I want to fill the column with data from the i+2th column (so from column C I go to column E). In order for this to happen, I want the first cell of (column E in this case) to stay the same, until column C is empty and the column starts taking values from column E.
I hope that this description gives a clear view of what I want to do.
Thanks in advance.
What I want to do is to fill a column with values of the first column in the data until the cells are empty. Then I want to fill the column with data from the i+2th column (so from column C I go to column E). In order for this to happen, I want the first cell of (column E in this case) to stay the same, until column C is empty and the column starts taking values from column E.
It's not the same kind of solution, but this might suit your needs better than your original formula:
=
IFERROR(INDEX(OFFSET($A$1,2,0,COUNTA(A:A)-1,1),ROW($A1)+0),
IFERROR(INDEX(OFFSET($B$1,2,0,COUNTA(B:B)-1,1),ROW($A1)+1-COUNTA(A:A)),
""))
If you need it for more than 2 columns, just extend the formula by following this pattern:
=
IFERROR(INDEX(OFFSET($A$1,2,0,COUNTA(A:A)-1,1),ROW($A1)+0),
IFERROR(INDEX(OFFSET($B$1,2,0,COUNTA(B:B)-1,1),ROW($A1)+1-COUNTA(A:A)),
IFERROR(INDEX(OFFSET($C$1,2,0,COUNTA(C:C)-1,1),ROW($A1)+2-COUNTA(A:A)-COUNTA(B:B)),
IFERROR(INDEX(OFFSET($D$1,2,0,COUNTA(D:D)-1,1),ROW($A1)+3-COUNTA(A:A)-COUNTA(B:B)-COUNTA(C:C)),
""))))
Sample implementation: https://i.stack.imgur.com/MAtxW.png
I've made considerations for your extra blank row between the header and the first row of data. For anyone wanting to use this formula without the blank row in their data set simply change the Offset-Row parameter from 2 to 1:
=
IFERROR(INDEX(OFFSET($A$1,1,0,COUNTA(A:A)-1,1),ROW($A1)+0),
IFERROR(INDEX(OFFSET($B$1,1,0,COUNTA(B:B)-1,1),ROW($A1)+1-COUNTA(A:A)),
""))
You can stick the formula anywhere in your worksheet, but don't forget to change the column letters to suit the location of your fields. In your case, probably:
=
IFERROR(INDEX(OFFSET($C$1,2,0,COUNTA(C:C)-1,1),ROW($C1)+0),
IFERROR(INDEX(OFFSET($E$1,2,0,COUNTA(E:E)-1,1),ROW($C1)+1-COUNTA(C:C)),
""))
Be aware that you need to make sure your columns don't contain rows with blank cells in between names, as this will cause it to skip an equal number of names at the bottom of the column.
EDIT:
I just realized your system uses semi-colons ";" to parse Excel formulas (mine uses commas ","). Please take note of that when copying these formulas to your spreadsheets. Here's the formula again but using ";"...
=
IFERROR(INDEX(OFFSET($C$1;2;0;COUNTA(C:C)-1;1);ROW($C1)+0);
IFERROR(INDEX(OFFSET($E$1;2;0;COUNTA(E:E)-1;1);ROW($C1)+1-COUNTA(C:C));
""))

How to report cell value to another cell on excel

I'm entering datas in A column of a table. According to the datas, I making sums from the yellow cell (actually this yellow cell is the high value of the A column). So all 10 cells, there is a sum until the end of datas.
I'm looking for automatically report the seven first grey cells (the sums)to another table. The problem is, according to the datas, high value is not at the same place so the sums are not to the same place too.
How can I do ?
Thank you for your help
MY ERROR :
And the message when I press ctrl maj enter in same time :
You might use this array formula in your report.
=INDEX($F:$F,SMALL(ROW($F$4:$F$117)+(100*(F$4:$F$117="")), ROW(F1)))&""
Bear in mind that, as an array formula, it must be confirmed with Control+Shift+Enter. Enter the formula in the row where you have Somme = 1, then copy down to 6. Note that Row(F1) is a counter. You have a similar counter (1 to 6) in F124:F130. Therefore you can replace ROW(F1) with $F124 (if that is where the "1" is) to make it easier to understand, perhaps.
The formula retrieves the value of the 1st, 2nd, 3rd etc non-blank cell in the range F4:F117. If those cells contain a formula they will be considered "blank" if their result equals "".
BTW, if you don't always have 113 results to evaluate you might consider giving a name to the range E4:E117. For example, if you name that range as "Results" then =SUM(Results) would be the same as =SUM($E$4:$E$117), but as you insert or delete rows within the named range the formula doesn't need to be amended. Use of a named range would simplify understanding your existing formula. You could do the same with column F.
Finally I find a solution to report the values from F to another table. As values positions are dependant of the MAX raw in E (every 10 cells) I make this formula :
For the first : INDEX(E4:F117;EQUIV(GRANDE.VALEUR($E$4:$E$117;1);$E$4:$E$117;0)+10;2)
For the second :
INDEX(E4:F117;EQUIV(GRANDE.VALEUR($E$4:$E$117;1);$E$4:$E$117;0)+20;2)
Etc...

Is there a 2 Value Look up function in MS Excel that can perform the following?

I am going crazy over this. It seems so simple yet I can't figure this out. I have two worksheets. First worksheet is my data. Second is like an answer key. Upon checking checking, A1:B1 in Sheet 1 is a match with the conditions in Row 52 in SHEET 2, therefore, the value in Column C is "MGC". What is the formula that will perform this function? It's really hard to explain without the data so I pasted a link of the sample spreadsheet. Thank you so much in advance.
sample spreadsheet here. https://docs.google.com/spreadsheets/d/1_AjuNfCdGfEM-XkqPa6W4hSIxQg4NM2Vg4c2C1pQ_vQ/edit?usp=sharing
screenshot here. (wont let me post i have no reputation)
In Sheet2, insert a column in front of Column A and put the formula in A2 =C2&D2.
Then in Sheet1, Cell C2 the formula =vlookup(A2&B2,Sheet2!A:B,2,0).
the first make a concatenated key to lookup, then the second looks up that key.
How about a index(match())? If I've understood correctly you need to match across both the A and B column in sheet one, checking for the relevant values in B and C on sheet 2 to retrun worksheet 2 column a to worksheet 1 column c.
third version try:
=INDEX(Sheet2!$C$1:$C$360,MATCH(Sheet1!A1&Sheet1!B1,Sheet2!$B$1:$B$360&Sheet2!$C$1:$C$360,0))
Basically what this does is use concatenation, the & operator, to specify you are looking for "Criteria A" & "Criteria B" in sheet 1, which makes the string "Criteria A Criteria B", which is supplied in the first part of the match function.
In the second it then says match this against all of my variables in sheet 2 in the same way with concantenation.
The final part of match function (0) specifies you want an 'exact' match
It then supplied this as a reference to the index function, which then finds the row intersecting with the value you want, and returns that.
As noted here https://support.microsoft.com/en-us/kb/59482 this is an array formula, so it behaves differently, and must be input differently. https://support.office.com/en-za/article/Guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7
There are (at least) 2 ways you could do this without VBA.
USING A SORTED LIST
The first relies on the assumption that your data can be re-sorted, so that everything "Unreported" is in the top, and everything "reported" is together below that (or vice versa). Assuming that this is the case (and it appears to already be sorted like this),we will use the function OFFSET to create a new range which shows only the values that align with either being "Unreported" or "Reported".
Offset takes a given reference to a point on a sheet, and then moves down/up & left/right to see what reference you want to return. Then, it returns a range of cells of a given height, and a given width. Here, we will want to start on Sheet2 at the top left, moving down until we find the term "Unreported" or "Reported". Once that term is found, we will want to move one column to the right (to pull column B from sheet 2), and then have a 'height' of as many rows as there are "unreported" or "reported" cells. This will look as follows in A1 on sheet 1, copied down:
=OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),1)
This says: First, start at cell A1 on sheet2. Then find the term in A1 (either "unreported" or "reported", on sheet2!A:A (we subtract 1 because OFFSET starts at A1 - so if your data starts at A1 we need to actually stay at "0". If you have headers on sheet2, you will not need this -1). Then, move 1 column to the right. Go down the rows for as many times as Sheet2 column A has the term found in Sheet1 A1. Stay 1 column wide. Together, this will leave you with a single range on sheet2, showing column B for the entire length that column A matches your term in sheet1 A1.
Now we need to take that OFFSET, and use it to find out when the term in Sheet1 B1 is matched in Sheet2 column B. This will work as follows:
=MATCH(B1,[FORMULA ABOVE],0)
This shows the number of rows down, starting at the special OFFSET array created above, that the term from B1 is matched in column B from sheet2. To use this information to pull the result from column C on sheet 2, we can use the INDEX function, like so:
=INDEX([FORMULA ABOVE],MATCH(B1,[FORMULA ABOVE],0))
Because this would be fairly convoluted to have in a single cell, we can simplify this by using VLOOKUP, which will only require the OFFSET function to be entered a single time. This will work as follows:
=VLOOKUP(B1,[FORMULA ABOVE],2,0)
This takes the OFFSET formula above, finds the matching term in B1, and moves to the 2nd column to get the value from column C in sheet2. Because we are going to use VLOOKUP, the offset formula above will need to be adjusted to provide 2 columns of data instead of 1. Together, this will look as follows:
FINAL FORMULA FOR SHEET1, C1 & COPIED DOWN
=VLOOKUP(B1,OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),2),2,0)
OPTION USING ARRAY FORMULAS
The above method will only work if your data is sorted so that the REPORTED and UNREPORTED rows are grouped together. If they cannot be sorted, you can use an ARRAY FORMULA, which essentially takes a formula which would normal apply to a single cell, and runs it over an entire range of cells. It returns an array of results, which must be reduced down to a single value. A basic array formula looks like this [assume for this example that A1 = 1, A2 = 2...A5 = 5]:
=IF(A1:A5>3,A1:A5,"")
Confirm this (and all array functions) by pressing CTRL + SHIFT + ENTER, instead of just ENTER. This looks at each cell from A1:A5, and if the value is bigger than 3, it gives the number from that cell - otherwise, it returns "". In this case, the result would be the array {"";"";"";4;5}. To get the single total of 9, wrap that in a SUM function:
=SUM(IF(A1:A5>3,A1:A5,""))
In your case, we will want to use an array formula to see what row in Sheet2 matches A1 from Sheet1, and B1 from Sheet1. This will look like this:
=IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW($B$1:$B$100),""),"")
This checks which rows in column A from sheet 2 match A1. For those that do, it then checks which rows in column B from sheet 2 match B1. For those, it pulls the row number from that match. Everything else returns "". Assuming no duplicates, there should only 1 row number which gets returned. To pull that number from the array of results, wrap the whole thing in a MATCH function. Now that you have the row number, you can use an INDEX function to pull the result in Column C with that row, like this:
FINAL ARRAY FORMULA METHOD
=INDEX($C$1:$C$100,MAX(IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW(Sheet2!$B$1:$B$100),""),"")))
Remember to confirm with CTRL + SHIFT + ENTER instead of just ENTER, when you type this formula. Note that I didn't refer to all of Sheet2!A:A, because array formulas run very slowly over large ranges.
The following formula should work without making any changes to the datasheets.
=INDEX(Sheet2!$A$1:$A$360,MATCH(Sheet1!A1,IF(Sheet2!$C$1:$C$360=Sheet1!B1,Sheet2!$B$1:$B$360),0))
Remember to save this formula as an array with CTRL+SHIFT+ENTER
Documentation on how to use INDEX and MATCH against multiple criteria can be found on Microsoft Support.
It's not clear what you want to do with the multiples that do not have corresponding matches. txed is listed as Unreported twice in Sheet1; kntyctap is listed as Unreported three times. There are only one corresponding match on Sheet2 for each of these.
Non-array Standard Formulas for multiple criteria matches
For Excel 2010 and above use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999,AGGREGATE(15,6,ROW(1:999)/((Sheet2!$B$1:$B$999=A2)*(Sheet2!$C$1:$C$999=B1)), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
For version of Excel prior to 2010 use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999, SMALL(INDEX(ROW($1:$999)+((Sheet2!$B$1:$B$999<>A1)+(Sheet2!$C$1:$C$999<>B1))*1E+99, , ), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
I've handled error with the IFERROR function in that latter formula. Excel 2003 and previous may have to use an IF(ISERROR(..., ...)) combination.

How to use a named column in Excel formulas

I know how to make a named range in Excel.
I have a spreadsheet, with various columns going across as parameters, and then finally a formula in the last cell. This is repeated many times in each row, with each row having a different set of data, and the formula updated to reference the correct row index.
However, the formula looks like (three rows worth):
=G2*(10*D2 + 20*E2 + 5*F2)
=G3*(10*D3 + 20*E3 + 5*F3)
=G4*(10*D4 + 20*E4 + 5*F4)
I would like to use named ranges, but I can't find a way to do something like
=Count * (10*var1 + 20*var2 + 5*var3)
where count, var1, var2, and var3 automatically update to be the particular column of the current row. I can create a named range for every cell, but that isn't helpful. I can name range the column, but then I can't find a way to put an offset into the formula.
Also the whole point of this is readability, so if it ends up being some nasty complex formula function call, that probably doesn't help too much.
Simple, at least when using Excel 2010:
name your column: select full column, enter name
use column name in formula; Excel will combine the referenced column with the current row to access a single cell.
Using the example from Alex P:
select column D by clicking the column header containing the "D", enter name "input1" into name field, and press Enter.
repeat for columns E to F, using "input2" and "input3", respectively.
Do not define additional names defining names "input1" [...] as in example above!
use the formula as given in the example above
Attention:
Using named columns this way, you cannot access any other row as the one your formula is in!
At least I'm not aware of the possibility to express something like <ColName>(row+1)...
I would suggest creating a Table. Select your range A1:H4, then go to the Tables widget > New > Insert Table with Headers (on Mac). This will mark A2:H4 as body of the table, and A1:H4 as header.
From that, you get:
Whatever you put into the header column will define the name for this column automatically, e.g. Count, Radius, Density, Height
You can then write your formula using =[#Count]*(10*[#Radius] + 20*[#Density] + 5*[#Height])
When you change the formula in cell H2, Excel will automatically "copy down" this formula to all cells in column H. So no more accidental inconsistencies in the formulas.
When you need to add another row, simply click the last cell (in our example H4) and hit Tab. Excel adds another row, and also makes sure to "copy down" your formula into the new row.
If you need a total row, add it with the Total Row checkbox in the Tables widget. Excel adds a total row automatically. If you click any cell in the total row, you can change the "total formula" with the "▼▲" button, for example to calculate the Average instead of the Sum of the column.
If you have a long table and scroll down so that the header is not visible anymore, Excel automatically displays the column header instead of the column names (Count instead of G for example).
I can really recommend the video You Suck at Excel with Joel Spolsky which explains all of that.
Suppose I have the following numbers set up in columns D to F in rows 2 to 4:
D E F G
2 10 15 20
3 1 2 3
4 20 30 40
Now suppose I want the value in column D to be known as input1, column E to be input2, and column F to input3:
In Insert > Name > Define...
input1 RefersTo =OFFSET(Sheet1!$D$2,0,0,COUNT(Sheet1!$D:$D),1)
input2 RefersTo =OFFSET(Sheet1!$E$2,0,0,COUNT(Sheet1!$E:$E),1)
input3 RefersTo =OFFSET(Sheet1!$F$2,0,0,COUNT(Sheet1!$F:$F),1)
Now if I write my formula in column G as follows I should get correct answers:
G2 =(10*input1+20*input2+30*input3) // 1000
G3 =(10*input1+20*input2+30*input3) // 140
G5 =(10*input1+20*input2+30*input3) // 2000
I haven't fully reviewed the previous answers, but I think this is closer to what #Jason Coyne the OP was looking for. So, I hope I get a lot of up votes. ;-)
Excel allows your formula to refer to tables and columns by name if you "Format as Table". Here is an article titled Using structured references with Excel tables that goes into detail.
FWIW, it looks like this feature has been available since Excel 2007.
Here is a screenshot of an example:
You should be able to see the formula in E2 is =[#Count] * (10*[#Var1] + 20*[#Var2] + 5*[#Var3]) which is pretty close to what #jason-coyne wanted to type.
I don't like that you are forced to pick a style (or define a new one if you don't see a style you like). The good news is you can reformat the cells all you wish without undoing the "tableness".
It insists on turning on auto-filter. But, auto filter is easy to turn off (see the Filter Button checkbox under the Table Tools Design menu).
It also insists on having non-empty, unique values in the header row (Which kinda makes sense). If you delete a header cell, or insert a column, Excel will invent a new, unique name and stuff it in for you. D'oh!
If you want a column to not have a header, you can enter an apostrophe (') followed by one or more blanks. Remember header values need to be unique, so keep adding blanks if you want more than one column without a header.
If you would like to download the sample workbook in the screenshot, here is a link: https://filebin.ca/3vfaSDn4NLEA/SampleWorkbook.xlsx
Adding to Alex P's answer:
Instead of using =OFFSET(Sheet1!$D$2,0,0,COUNT(Sheet1!$D:$D),1) as the formula for input1, I recommend to use =Sheet1!$D$2:INDEX(Sheet1!$D:$D,COUNT(Sheet1"$D:$D))
It produces the same result, but it is non-volatile, i.e., only recalculate when a predecessor cell changes. This is much better in a larger model!
If you're using VBA, then you can select the whole column and name it, say MyCol, in the name box (upper left input box). The in your code you can refer to a cell in the column MyCol (line 12) using the following code:
Cells(12, Range("MyCol").Column)
You might be able to use the row() function. This returns the current row that you are in. So depending on the layout of the spreadsheet you can use it like this:
=offset(NamedColumn1, row()-1)
The -1 is because you are saying how many rows to move down from row 1 which if you are in row 1 you want to be 0.
Use the Excel feature called named references.
To name a cell or range of cells
select that cell or range of cells
Enter its name in the Name Box ( its left of the formula widget and has the cell name )
You can't use names that conflict with cell names, like k0.
The named cells can be used if formulas. E.g.,
=pi*radius*radius
I'd like to propose a slight variation of the cell reference made by Dror. This will work as well:
Range("MyCol").Rows(12)

Resources