I'm trying to use IF to return a value that depends on the position of one cell relative to another in the same column.
Spreadsheet Example
If you click the above image, you'll see a number of columns with the possible values of "No," "Yes," "Yes>No," and "No>Yes."
The equation will go in the "Category of Change," row, one equation for each column. If the "Yes>No," is lower in the column than the "No>Yes," I want to return "Less Frequently," and if the opposite is true, I want to return "More Frequently" ("Same," if there is no "Yes>No," or "No>Yes").
I've tried using ARRAY and INDEX functions, but I'm not sure how to get Excel to "look" for each of those values, and then compare their ranking in the column.
Thank you in advance for your help!
MATCH will return the relative row number. This assumes the first column of data is in E2:E8.
=IFERROR(IF(MATCH("Yes>No",E2:E8,0)>MATCH("No>Yes",E2:E8,0),"Less Frequently","More Frequently"),"Same")
It is looking for exact matches, so if you have typos, it will always default to Same. If only one is found then it will still produce Same
You would put int he first cell and copy/drag over, the references will change automatically.
Related
My file looks something like this
image
An IF statement would be too long considering I have 20 different long formulas.
Update: I later tried to use an IF statement but failed because it depended on substitute function to replace cell references in the equation but substitute returned a string which coudn't be used as a function by IF.
User should be able to increase available rows by simply copy and insert the previous row.
I can use index match to copy a cell's value which contain the right formula according to the dropdown list but when the user select the same item again I can't update the formula with the new values without affecting the previous cell which used the same formula.I couldn't find a way to copy the same formula several times and replace cell references in it (without human interaction like search and replace) i.e. by using Substitute function which couldn't replace cell references as it looks through the cell's value not it's formula (the cell which contain the main formula).Here is one of the 20 formulas I have
=(Tables!O167*144/(Tables!O158*Tables!O159)/4005)^2*INDEX(Tables!A159:L200;MATCH(INDEX(Tables!A159:A200;MATCH(TRUE;INDEX(Tables!A159:A200>=Tables!O158*Tables!O159/(Tables!O160*Tables!O161);0);));Tables!A159:A200;0)+MATCH(INDEX(Tables!B159:B200;MATCH(INDEX(Tables!A159:A200;MATCH(TRUE;INDEX(Tables!A159:A200>=Tables!O158*Tables!O159/(Tables!O160*Tables!O161);0);));Tables!A159:A200;0)+MATCH(INDEX(Tables!B159:B200;MATCH(TRUE;INDEX(Tables!B159:B200>=Tables!O164/(2*Tables!O158*Tables!O159/(Tables!O158+Tables!O159));0);));Tables!B159:B200;0)-1;);Tables!B159:B200;0)-1;MATCH((INDEX(Tables!C158:L158;MATCH(TRUE;INDEX(Tables!C158:L158>=Tables!O163;0);)));Tables!A158:L158;0))I tried to use FORMULATEXT to convert the formula into a string then use substitute to replace the cell references then use the depreciated Evaluation function but hit the 255 char limit. I searched a lot on google but to no avail, I don't mind a VBA code but a macro free method would be better, Thanks.
TL;DR: Is there a way to copy a formula stored in a cell and replace some of the cell references then enter it in another cell multiple times with different cell references each time ??
Try this in E2 and fill down.
=CHOOSE(MATCH(LOWER(LEFT(A2)), {"r","s","t"}, 0), B2*C2, B2^2, B2*C2/2)
In a spreadsheet formula, (namely SumIfs) I would like to be able to select a column range using its delimiters instead of a A1:A3456 style, like I would do in VBA [Range("A1:A3456")~Range(Cells(1,1),Cells(3456,1))].
If this is not possible, is there any workaround to use the result of a 'Match' function to get the column number where I want to apply certain criteria?
My function would look like
=Sumifs(A2:A10;*{range(cells(1,match(Z5;A1:T1)), cell(10,match(Z5;A1:T1))}*,"="&1)
...if only I could add vba formulas inside the spreadsheet.
You can use a combination of Address and Indirect, like this:
=SUM(INDIRECT(ADDRESS(1,1) & ":" & ADDRESS(3456,1)))
which is equivalent to =SUM(A1:A3456)
ADRESS transforms from style Cells(i,j) to style A1.
INDIRECT serves to interpret the resulting string as a range address.
SUM here is an example of usage.
Well It's a bit ugly, but if you want to do that occasionally and don't want to switch completely to RC-style, it's probably the easiest way.
Use Offset, which is much richer as a worksheet function than it is in VBA.
Syntax
OFFSET(reference, rows, cols, [height], [width])
The OFFSET function syntax has the following arguments:
Reference Required. The reference from which you want to base the
offset. Reference must refer to a cell or range of adjacent cells;
otherwise, OFFSET returns the #VALUE! error value.
Rows Required. The number of rows, up or down, that you want the
upper-left cell to refer to. Using 5 as the rows argument specifies
that the upper-left cell in the reference is five rows below
reference. Rows can be positive (which means below the starting
reference) or negative (which means above the starting reference).
Cols Required. The number of columns, to the left or right, that
you want the upper-left cell of the result to refer to. Using 5 as the
cols argument specifies that the upper-left cell in the reference is
five columns to the right of reference. Cols can be positive (which
means to the right of the starting reference) or negative (which means
to the left of the starting reference).
Height Optional. The height, in number of rows, that you want the
returned reference to be. Height must be a positive number.
Width Optional. The width, in number of columns, that you want the
returned reference to be. Width must be a positive number.
from https://support.office.com/en-us/article/OFFSET-function-c8de19ae-dd79-4b9b-a14e-b4d906d11b66
I have a spreadsheet with column A having a list of names in it. I then have a userform that uses those names to make an attendance report. When The enter button is pressed it takes the name and finds what row that name is at then finds the next empty cell in that row and puts the info in that cell. My question is how do I search for that name and get the row that is associated with that name? I have done some research but what I have found I didn't quite understand how they are being implemented. I thought about vlookup but wasn't sure if that would give me the row number?
You could use a quick Match():
=Match("MyName",$A$1:$A$10000)
That should return the row number. Note this is relative. If the name is in A1, the above will return 1.
If you do this, however, =match("myName",A2:A100), and the name is in A2, it will also return 1.
Edit: Sorry, for VBA this should work worksheetfunction.Match(neName.Value,Range("A1:A100"),0)
I am having trouble changing the title of some columns in a pivot table. I'm trying to make them have dates in them. Each date 6 days further from the last.
Like this
But, I cannot get an equation inside the column title to stay, every time I type in the equation and press enter, it evaluates to either 0 (If the format of the cell is number or general), or 1/0/1990 (If formatted as a date). I checked the value of the cell by =ISTEXT(A1) and it evaluates as true. No matter how I format the cell. So I can never change the title to look like the picture. Any ides?
Here is what I have.
TRUE is the result from ISTEXT()
Even if I manually enter in the formula via the function arguments, it'll show up correct, but when I click ok. It will go back to either 0 or 1/0/1990
Here's the original page
https://drive.google.com/file/d/0B3p8Jm7oNAo4ZUN0Qk1mR1cxYmM/view?usp=sharing
In Excel, dynamic values (formulas) in the header of a table-formatted table are not allowed.
Instead, you can first generate your table header and then format the table as (pivot-)table. You should get a message saying that the header row will be converted in static text (with correct format).
This is my first time using this forum, and my VBA skill is not very well developed. I hope someone can help.
I have two columns of data, Column A and Column B.
Column A - Returns a sequential "month-year" or 0. If spreadsheet current date (=now()) is less than say Feb, then the cell for February returns 0.
Column B - I want this column to check each cell in Column A. If Column A cell has a date identifier, I want this to be placed in Column B. If Column A has a 0 identifier, I want Column B to return an "empty" cell.
Reason why I am doing this is I am graphing a bar chart. When I trick the program into making an empty cell (x-axis) the graph does not show any data for that month (which is what I want). Trying to make a dynamic graph, but I have no experience in VBA (only C programming =/).
You don't need VBA (or even formulas) to do this.
Highlight Column A (the entire column), copy it.
Highlight Column B (the entire column, right click, Paste Special, select values and number formats, okay.
Highlight Column B again. Press Ctrl+H, Type 0 (or failing that it might be 00/01/1900) in the 'find what', leave the 'replace with' one blank. Tick Match entire cell contents. Click replace all.
Done.
Instead of trying for an empty space (which would be impossible, as there's a formula in that cell), use an error condition.
Use this formula, and copy down:
=IF(A1=0,NA(),A1)
This will return the error condition #NA! and Excel will leave the column blank
The other way would be to have a dynamic range for the chart data - I have a chart that will adjust to 5,6 or 7 days, depending on the data returned for the week. The Horizontal (Category) Axis Labels is set to a named range (='Sample.xlsx'!LastWeekRange) and the range checks the data, and returns the appropriate number of cells.
LastWeekRange is defined in Name Manager as =OFFSET(Data!$A$3,0,0,IF(Data!$F$9>0,7,IF(Data!$F$8>0,6,5))), which returns A3:A7 if there's nothing in F8, A3:A8 if there is something in F8 but not in F9, and A3:A9 if there is something in F9.