When one "Fills right in excel" , the Column name updates
eg.
1st cell
is
=A2
If I fill right the next cell will be =B2
But rather than the column incrementing I want to increment the row number
so 1st cell is
=A2
The cell on its right is
=A3
how do i do that?
If you're putting the first formula in B2 then
=OFFSET($A$2,COLUMN()-2,0)
The -2 part is because we're starting in column B. You need to change it for whatever column you're actually starting in such that the second argument equal zero.
You can do this using the INDIRECT function. Suppose we want formulas in cells B1, C1, D1... that should reference A2, A3, A4... Starting in cell B2 we can enter:
=INDIRECT("R[" & COLUMN(RC)-1 & "]C1", FALSE)
In cell B2, this will render as:
=INDIRECT("R[1]C1", FALSE)
In this situation, I'm using R1C1 format. The second parameter to the INDIRECT function tells the function to use R1C1 format. The function itself (again in cell B2), says "give me what is in the cell that is one row down and the first column". In the original formula, by basing the row value on the current column number, it will update the formula to a new row as you fill right.
Now, if you are asking if there is a way to do this using the GUI like say using the Fill box with the mouse, the answer is no. There is no means to transpose the fill using the GUI.
Related
Is there a way to create a formula in one cell that will change the value in another cell based on some criteria, without scripting? Example: cell a1 contains a numerical value. cell b1 contains a value from a drop-down list, say, "YES,NO". If cell b1 is set to "YES" I want to remove (set to zero) the value in cell a1. What I'd like to do is have a formula in cell c1 that interrogates b1 and sets the value in a1 accordingly. Is the only way achieve this writing code and using setValue?
you cant remove it without a script. you can visually hide it in various ways. if the A1 is subject of further sum (as in your case per your comment) the sum formula can be always altered to reflect desired output. example:
if your formula is
=SUM(A1, C5, D22)
you can do
=SUM(IF(B1="YES", 0, A1), C5, D22)
Use the following on the cell you need the calculation (or zero) on:
=IF (B1="YES",0,SUM(A:A))
Using the given formula, you would do the SUM calculation for the whole Column A if the value on B1 is "YES", if not, then a 0 would be placed on the cell you put the formula on.
I have a column that contains text cells and date cells. Next to each cell of text, I need the nearest cell that is above that text and contains a date to be returned.
Example
You can use INDEX/MATCH:
=IFERROR(INDEX($A$1:A1,MATCH(1,$A$1:A1,-1))/(ISTEXT(A1)),"")
You have to use a column agent (English is my second language so please give me a better way to describe it if you know), let's say column C.
Put this formula to C1:
=A1
Put this formula to C2 and fill down:
=IF(ISERROR(DATE(DAY(A2),MONTH(A2),YEAR(A2))), C1, A2)
The above formula check if A2 is a date then copy it or fill it down by the cell above.
Copy the cells you want in column B (B2:B4,...) from column C. Hide column C if you want.
Try below formula.
=IF(ISTEXT(A1),AGGREGATE(15,6,$A$1:$A$10,COUNTIF($A$1:$A1,">1/1/1900")),"")
If there are numbers also in cells rather that names then you can use below formula
=IF(LEFT(CELL("format",A1),1)="D","",AGGREGATE(15,6,$A$1:$A$10,COUNTIF($A$1:$A1,">1/1/1900")))
You can also use the LOOKUP function:
B1: =IF(ISNUMBER(A1),"",LOOKUP(2,1/($A$1:A1),$A$1:A1))
and fill down.
From my research, when a bunch of cells are merged, you can only reference the first row and first column of the merged cells. EG. if A1:A3 are merged, then I can only access the data using A1 only, and A2 and A3 returns 0.
Now let's say I have a column B that has a formula that calculates based on values in column A. If I drag this formula down, then B2 and B3 will end up using value of 0, when they should be using value in A1.
Effectively, what i want to do is "if the cell in column A (of this row) is blank, then use the last non-blank value going upwards".
I know this will need to combine a couple of formulas, but I can't figure out how to create this. For a start, I can use the Offset function to "go up", but the difficult part here is how to find the previous non-blank cell?
I also tried combing OFFSET with COUNTA (see https://www.exceltip.com/other-qa-formulas/get-the-value-of-the-last-non-blank-cell-in-a-column-in-microsoft-excel.html), but this doesn't work if this occurs multiple times.
Easiest way is to use a helper column:
In B2 write
=IF(NOT(ISBLANK(A2)),0,B1+1)
and in C2 write
=OFFSET(A2,-B2,0)
Edit: actually... the solution without helper column is even easier! Write in B2:
=IF(ISBLANK(A2),B1,A2)
To avoid the helper column, you can use the INDEX + AGGREGATE functions:
=INDEX($A$1:A1,AGGREGATE(14,6,($A$1:A1<>"")*ROW($A$1:A1),1))
Short summary, to refer to the cell C5, rather than saying =C5 , i need to use =C(a+b) , because the row number is variable and calculated using a formula, but the reference =C(a+b) doesn't work.
In Microsoft Excel, I am using =MATCH(A1, B:B, 0) to get the row number at which the value at A1 exists in Column B. For eg it returns 5. How do i refer to Column C and Row[returnedValue] i.e. C5 if i am writing the formula in one line? i.e. i tried using
=C(MATCH(A1, B:B,0)) to refer to Column C and Row 5 , but it doesn't work.
The INDIRECT function will do this for you.
To Test ...
Put the words "This is a test" in cell A1.
In cell A2, put the text "1"
In cell A3, put this formula ...
="A" & A2
Finally, in cell A4, add this formula ...
=INDIRECT(A3)
... that should then return the text within A1.
This demonstrates how it works so you should be able to apply it to your scenario. I suspect something like this will work for you?!? ...
="C" & (MATCH(A1, B:B,0))
... barring additional error checking of course.
I have a vague memory doing this a year back and want to repeat the function. I want to use B2 as a reference to my formula, where my formula is reading in values from another tab and can be expanded by dragging and dropping. My picture is trying to illustrate the issue,
The pink cells are not using the reference cell B2, heading Formula 1 show the formula in column B.
The blue cells is what I have now, column D is the results from the formula in column E (row by row). Here I have created the formula in cell D4 and then dragged it down to D6.
The green cell is what I want to achieve, note the discrepancy marked in red.
I want to be able to write the formula in cell D4 and then drag it down to D6. How can this be done without adding new columns.
Use this:
=INDIRECT("'" & $B$2 & "'!C" & ROW())
I added '' around the sheet name in case the sheet name in B2 contains spaces.