Sum by row with reference to other cell values - excel

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.

Related

Fill blank value in Excel

Need help in Excel for the following problem
ColA ColB
A1 B1
A2 B2
A3 B3
A4
A5 B5
A6 A6
A6
A6
if Column B is blank, I need to copy the value of ColA into ColB. But if the value is already present, then no action is needed.
Is it with formula or Vba?
A formula like should be ok (you copy/paste this formula to every cells in your Col)
=IF(B1="",A1,B1)
In column C enter the following formula:
=IF(B1="", A1, B1)
Copy this formula down column C. Then, assuming it looks right, you may delete the current column B, leaving the new column to become the new column B.
It is important to note that this formula won't work if directly entered into column B. In that case, Excel would complain about a circular reference.
Highlight the entire column B used range and press Ctrl+F to open find and replace then insert select
find " " (leave blank)
replace =OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),,-1,1)
Which looks like:
Result:
This, INDIRECT(ADDRESS(ROW(), COLUMN()), refers to the cell itelf, and -1 column offset argument refers to column to left.
You can then do copy paste as values to convert formulas to hard coded values.

Insert a value to a cell in excel using formula in another cell

I need to insert a value to a cell in excel using formula in another cell.
Say
A1 = "Test"
B1 = formula to insert A1 to C1
C1 = A1
Can I write a formula in B1 to insert value in C1?
I don't need any formulas in C1.
If Yes, What should be the formula?
If there it is next to the cell AND has no value in B2, it is possible, otherwise it is not.
Use Split()
Split(CONCATENATE("Text for B1#Sperator$$",A1),"#Sperator$$",FALSE)
It really depends.
EDIT
Out dated. Only works in google sheets.
Without using VBA or formulas in column C you can't achieve this.
A simple solution using formulas:
In cell C1, paste the following formula and drag it down:
=IF(B1=1;A1;"")
So if the content of cell B1 is equal to 1, your cell at column C will display the respective value of the same row at column A.

How to randomly select cell and the adjacent cell on excel

I am trying to find a formula on excel that will allow me to randomly select a cell between a range (this part I have found a formula for) and have the value pasted into another cell AND then have the cell next to the randomly selected cell's value also selected and pasted into a different cell.
Not sure if this makes sense so I will explain what I'm trying to do.
I have a column full of years and the adjacent column full of prices that correspond to each year. I want a year randomly selected and pasted into a cell lower down on the spreadsheet, and I want the corresponding price for this randomly selected year pasted next to this cell.
Thank you in advance!
Anna
Say the data is in A1 through B10
In D1 enter:
=INDEX(A1:A10,RANDBETWEEN(1,10))
and in E1 enter:
=VLOOKUP(D1,A1:B10,2,FALSE)
Another approach is to enter:
=RANDBETWEEN(1,10)
=INDIRECT("A" & C1)
=INDIRECT("B" & C1)
In C1 through E1
(Either approach will work if column A contains years rather than names)
Yet another approach is to enter:
=RANDBETWEEN(1,10)
=INDEX(A1:A10,C1)
=INDEX(B1:B10,C1)
In C1 through E1

Excel Transpose and Link Simultanously

I know how to link on cell to another so that its content changes to match the source cell.
I know how to transpose a row into a column.
Is there any way to transpose a row into a column with links that dynamically adjust to match their source?
Try locking your cell references before transposing them. Turn your formula from:
=B2
to
=$B$2
If you do not add the $ to the row and column part of the cell address, the address will change during the transpose operation.
In my example, I filled the cells A1 to E1 with their a1 to e1 to match their cell address. In the row below, I put =$A$1 in A2 and so on to =$E$1 in E2. You will notice the formula for E2 in the formula bar from this screen shot:
I then selected the cell for the top of my transposed column (in my case C4) and right clicked and selected paste special: (note there is a short paste transpose, but I cold not get the right click menu to screen shot)
And here we see the transposed column with the formula in C4 is =$A$1 and the formula in C8 is =$E$1

Excel : Increment Row number on fill right

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.

Resources