Dragging cells with formulas keeping same sequence logic - excel

I have some value in cell a1 and these formulas in other cells:
in cell a2: =$a$1+1
in cell a3: =$a$1+2
in cell a4: =$a$1+3
when I select cells a2:a4 and drag down until cell a7 in order to fill the formulas with continuation of the same logic, I get same formulas:
in cell a5: =$a$1+1
in cell a6: =$a$1+2
in cell a7: =$a$1+3
Instead of:
in cell a5: =$a$1+4
in cell a6: =$a$1+5
in cell a7: =$a$1+6
Is there a way to achieve this result by dragging?

Try this in A2:
=$A$1+Row(1:1)
Now as you drag down the Row(1:1) will change to Row(2:2),Row(3:3) and so forth. Thus adding the needed number.

Your sample may have been over-simplified but this should work in A2.
=$A1+1
Dragged down it will result in,
=$A2+1
=$A3+1
(etc)

You can do this without the formulae as well. Since what you want is basically an increasing series by 1, under your cell A1; enter your value in A1 (e.g. 2.3618), and hold the Ctrl button on your PC (not sure about Mac), and drag the bottom right corner of the cell A1 downwards as far as you want. (Also known as Fill Series)
PS: This doesn't work if A1 has irrational numbers (like sqrt(2), pi(), etc.)

Related

Google Sheets or Excel: setting the value of a remote cell from a formula

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.

Highlight A1 if A2 does not equal A1, B1 does not equal B2, and so on

For example, I have A1 that has a formula to add the sum of multiple other cells, then A2 I enter a number each week. A1 and A2 must match, if they don't then a mistake has been made. I want Row 2 to highlight if it does not match. I can figure this out but I cannot figure how to copy that in conditional formatting to apply to B1 and B2, C1 and C2, D1 and D2, E1 and E2, and so on.
From what I understand, you want to have row 2 highlighted if any of the cells in it is different from the corresponding cell in row 1. You do not want to have highlighted only the offending cells.
The only way I know to do it, short of VBA, is to create a helping row, let's say row 3, where you put =A1=A2 in cell A3, then copy it to the entire row. Then, while cell A2 is active, select the entire row 2, and create a conditional formatting rule with formula =NOT(AND(3:3))
UPDATE 03/04/21 Here a faster method (no helping row):
Select the row 2, and in the Conditional Formating, put this formula:
=SUMPRODUCT(-(1:1<>2:2))<0

MS Excel direction change of drag down reference

Suppose, in Cell A1 of Sheet2 I use this formula.
=AVERAGE(Sheet1!A1:A10)
Now when I drag down from A1 to A3
A2 will be =AVERAGE(Sheet1!A2:A11)
A3 will be =AVERAGE(Sheet1!A3:A12)
However I want it in a transpose way. Such as,
A2 will be =AVERAGE(Sheet1!B1:B10)
A3 will be =AVERAGE(Sheet1!C1:C10)
Means, I will use drag down rather than dragging to side, yet I'll get the answer in transpose way, more specifically, I want to change column index rather than changing row index by dragging a formula down.
Is there any way to do that?
Thanks in advance.
One way is to use this formula in Sheet2 A1 and copy down
=AVERAGE(OFFSET(Sheet1!$A$1,,ROW()-1,10))
As you drag it down, ROW()-1 increases by 1 and this is the column offset from A1.
In A1, ROW()-1 returns 0 so there is no offset, but as you go down this increases by 1 and this is the column offset from A1 - so in row 2 this becomes B1 etc.
The 10 indicates the size of the relevant range to be averaged.
In A1 enter:
=AVERAGE(INDEX(Sheet1!$A$1:$Z$10,1,ROW()):INDEX(Sheet1!$A$1:$Z$10,10,ROW()))
and copy downward.
If you need more than 26 items, increase the Z in the formula.

Sub a number with column numbers and show the results in a row

I have a number in cell B2 and I want to make a sub this number with each number in the column C.
The results will be presented in a row (and I want to use the cross in the right corner of the cell to autofill).
Let me explain you what I want to show in each cell:
E2: $B$2-C5
F2: $B$2-C6
G2: $B$2-C7
In order not to write it manually in each cell, how can I change it (autocomplete C5, C6, C7) with the usage of the cross?
I tried to use the dollar like $B$2-$C5 and then drag the cross but it fills all the cells with the C5 value and not C6, C7 etc
In E2 enter:
=$B$2-INDEX($C:$C,COLUMNS($A:E))
and copy across:

How to create formula in excel that can iterate in specific range?

I want to fill down 10 cells with value from B10 cell:
='Disconnect Minor Reason List'!$B$10
Then I want to get another 10 cells with value from B11 cell, then another 10 from B12 and so on.
Is it a possible in Excel?
First approach (better one, since it's not volatile):
write formula in E10 cell: =B10
write formula in E11 cell: =INDEX($B$10:$B$12,1+INT(COUNTA($E$10:E10)/10))
and drag it down.
Second approach: (if you'd like to use single formula)
use this formula in E10 and drag it down:
=INDEX($B$10:$B$12,1+INT((ROW()-ROW($E$10))/10))

Resources