How to reference every cell of another tab using indirect - excel

I want to create a tab that will display all the cell values of another tab based on the tab name provided on a cell.
I have played around with the indirect function, but I cannot write a formula so that by dragging down and right it will access the cells.
=INDIRECT("'"&$A$1&"'!A1")
This part &$A$1& is getting the name of the tab.
If I drag down this formula, the last A1 does not change though.

You can use the formula ="Sheet2!A1" in Sheet1 Cell A1 and drag down, then across. I tried to find a faster way to paste it into every cell, but I had to force quit the application because it used all of my available memory. You might think about whether you actually need every cell to be duplicated into the second sheet. Good luck!
Edit: Just realized you were dead set on using Indirect. This should work.
=INDIRECT("'Sheet2'!"&CELL("address",A1))

Simply use following formula
=INDIRECT($A$1&"!A" & ROW(1:1))

Try building the string like this. The final A1 will work as you want it to.
=INDIRECT(CONCATENATE("'",$A$1,"'!", CELL("address",A1)))

Related

Excel Fill alphanumeric values

I would like to fill A000001, A000002, till A100000.
Now do it by dragging the fill handle.
I also tried to fill using Step Value and Stop Value. It works for 1,2,3 to 100000. But it does not work for alphanumeric filling like A000001, A000002 etc
Use the step value method to generate 1 to 100000 in column A (from cell A1). And paste the below formula in cell B1,
=IF(LEN(A1)=1,"A00000"&A1,IF(LEN(A1)=2,"A0000"&A1,IF(LEN(A1)=3,"A000"&A1,IF(LEN(A1)=4,"A00"&A1,IF(LEN(A1)=5,"A0"&A1,IF(LEN(A1)=6,"A"&A1))))))
Just double click the fill handle in B1 to generate for the entire range. This is a simpler way of doing this. Hope this helps.
The standard method is Create custom list but since you are looking for a long one so practically impossible,, another is Flash Fill,, and older one is write A000001 in cell A000002 in below cell select both drag it till you need.
I know its too late, however I can provide a tip it may be helpful to someone looking for same issue.
if you want fill the alpha numeric series by dragging the fill handle, just need to add a simple formula in the first row:
="A"&TEXT(ROWS($1:1),"000000")
In the above formula: the text “A” is constant, you can change them to your needed text, and the number “000000” is the variable which will be increased by dragging the fill handle.
Also if you want to add a string at end , you just need to change the formula to this,
="A"&TEXT(ROWS($1:1),"000000")&"-VAL"
Then it will give you something like this,
A000001-VAL, A000002-VAL, A000003-VAL.....
You can also change the starting number too.
Regards

Find and replace with wildcards

I want to change the formulas in a 200x200 table by using find and replace.
My old formula is ='Sheet1'!A1*IF(B4=C2,1,0) and I want to replace it with =('Sheet1'!A1-'Sheet1'!B1)*IF(B4=C2,1,0)
Since doing it a cell at a time is tedious, I tried to use find and replace, but I could not keep the referenced cells. Is there a way to do it?
This is how the first cells of my data look like
I cannot fill down or right, since if I fill down I want to keep the reference to C2 while changing the reference to B4 (something like B4-$C$2), while if I fill right I want to keep the reference to B4 and change the reference to C2 (something like $B$4-C2)
I think I might have a bit of a workaround, I'd use it for one cell, and then mess about with the IF references depending on your needs for expanding down and right, as without seeing your dataset it's hard to envisage exactly how you want it, I hope this gives you the right idea, but may need a bit of messing about with.
Firstly, you want to get the cell with your original forumula in (let's say it's in A1). In an empty cell (let's say B1), you want to put =FORMULATEXT(A1). Then in another empty cell (let's say C1), you want to put:
="=(" & MID(B1,2,10) & "-Sheet1!B1" & ")" & MID(B1,11,20)
One thing to also maybe note is that my Excel doesn't produce quotes around the Sheet names, so you may need to mess about with the MID numbers (so probably change the 10 in the first mid to a 12, I think?) I've put the final MID number as 20 just to account for longer formulas.
Copy the cell. Now go to a new worksheet and in A1, you want to right click and paste values. Now, this part is important, you want to click into the formula bar and then press enter. This should now give the formula:
=(Sheet1!A1*-Sheet1!B1)*IF(B4=C2,1,0)
Now you can go into the formula bar, copy this and paste it back into your original sheet. Like I said, you should then mess about with the $ for the IF statement depending on your needs for expanding the data. Sorry it's a bit of a long workaround, but it's all I can find to do!

How to avoid manually entering this formula in Excel

I'm trying to calculate a value called, "additional throughput". It is calculated by subtracting the base case module's throughput from a new module's throughput.
In the sheet below you can see that for the third row down (has a blue box in it), that the additional throughput is calculated by the formula "=T6-T4".
The problem is that when I click on this box and drag it down to apply the same formula to the other rows, I want the formula to become "=T7-T4" for the next row. Instead it becomes "=T7-T5". I tried to select multiple cells (where the formula was manually entered) before dragging down so it could recognize that the T4 doesn't change, only the first part. However, that didn't work.
In Excel you can use $ signs before the column or row references to make those references "absolute" (rather than "relative"). For example if you use =A$1 then the 1 doesn't change when you copy down. If you use =$A1 then the A doesn't change when you copy across. If you use =$A$1 then neither changes whichever way you go.
So for your case you need to use
=T6-T$4
when you copy that down T$4 doesn't change
You have to make the cell address of T4absolute by pressing F4, so it becomes $T$4. When you then copy the formular to other places T4 will keep its absolute address.
I figured it out.
You put a $ symbol in front of the row and column you want to not change. This is referred to as an absolute reference.
Found out how to do it here:
How do I change an Excel relative cell to an absolute cell?

Repeating a formula in a column in Google Docs

I have struggled for a long time with this. I need to enter the same formula in every cell of a column. However it changes the formula as it is dragged or copied. e.g. =J2 becomes =J3 =J4 etc. I need just =J2 in every cell.
Try =$J$2 instead of =J2
The $ symbol keeps the reference as-is, that is does not change it when it is dragged.
HTH.

Excel Reference To Current Cell

How do I obtain a reference to the current cell?
For example, if I want to display the width of column A, I could use the following:
=CELL("width", A2)
However, I want the formula to be something like this:
=CELL("width", THIS_CELL)
Several years too late:
Just for completeness I want to give yet another answer:
First, go to Excel-Options -> Formulas and enable R1C1 references. Then use
=CELL("width", RC)
RC always refers the current Row, current Column, i.e. "this cell".
Rick Teachey's solution is basically a tweak to make the same possible in A1 reference style (see also GSerg's comment to Joey's answer and note his comment to Patrick McDonald's answer).
Cheers
:-)
Create a named formula called THIS_CELL
In the current worksheet, select cell A1 (this is important!)
Open Name Manager (Ctl+F3)
Click New...
Enter "THIS_CELL" (or just "THIS", which is my preference) into Name:
Enter the following formula into Refers to:
=!A1
NOTE: Be sure cell A1 is selected. This formula is relative to the ActiveCell.
Under Scope: select Workbook.
Click OK and close the Name Manager
Use the formula in the worksheet exactly as you wanted
=CELL("width",THIS_CELL)
EDIT: Better solution than using INDIRECT()
It's worth noting that the solution I've given should be preferred over any solution using the INDIRECT() function for two reasons:
It is nonvolatile, while INDIRECT() is a volatile Excel function, and as a result will dramatically slow down workbook calculation when it is used a lot.
It is much simpler, and does not require converting an address (in the form of ROW() COLUMN()) to a range reference to an address and back to a range reference again.
EDIT: Also see this question for more information on workbook-scoped, sheet dependent named ranges.
EDIT: Also see #imix's answer below for a variation on this idea (using RC style references). In that case, you could use =!RC for the THIS_CELL named range formula, or just use RC directly.
You could use
=CELL("width", INDIRECT(ADDRESS(ROW(), COLUMN())))
=ADDRESS(ROW(),COLUMN(),4) will give us the relative address of the current cell.
=INDIRECT(ADDRESS(ROW(),COLUMN()-1,4)) will give us the contents of the cell left of the current cell
=INDIRECT(ADDRESS(ROW()-1,COLUMN(),4)) will give us the contents of the cell above the current cell (great for calculating running totals)
Using CELL() function returns information about the last cell that was changed. So, if we enter a new row or column the CELL() reference will be affected and will not be the current cell's any longer.
A2 is already a relative reference and will change when you move the cell or copy the formula.
=ADDRESS(ROW(),COLUMN())
=ADDRESS(ROW(),COLUMN(),1)
=ADDRESS(ROW(),COLUMN(),2)
=ADDRESS(ROW(),COLUMN(),3)
=ADDRESS(ROW(),COLUMN(),4)
Without INDIRECT(): =CELL("width", OFFSET($A$1,ROW()-1,COLUMN()-1) )
I found the best way to handle this (for me) is to use the following:
Dim MyString as String
MyString = Application.ThisCell.Address
Range(MyString).Select
Hope this helps.
Inside tables you can use [#] which (unfortunately) Excel automatically expands to Table1[#] but it does work. (I'm using Excel 2010)
For example when having two columns [Change] and [Balance], putting this in the [Balance] column:
=OFFSET([#], -1, 0) + [Change]
Note of course that this depends on the order of the rows (just like most any other solution), so it's a bit fragile.
There is a better way that is safer and will not slow down your application. How Excel is set up, a cell can have either a value or a formula; the formula can not refer to its own cell. You end up with an infinite loop, since the new value would cause another calculation... . Use a helper column to calculate the value based on what you put in the other cell. For Example:
Column A is a True or False, Column B contains a monetary value, Column C contains the folowing formula:
=B1
Now, to calculate that column B will be highlighted yellow in a conditional format only if Column A is True and Column B is greater than Zero...
=AND(A1=True,C1>0)
You can then choose to hide column C
Full credit to the top answer by #rick-teachey, but you can extend that approach to work with Conditional Formatting. So that this answer is complete, I will duplicate Rick's answer in summary form and then extend it:
Select cell A1 in any worksheet.
Create a Named Range called THIS and set the Refers to: to =!A1.
Attempting to use THIS in Conditional Formatting formulas will result in the error:
You may not use references to other workbooks for Conditional Formatting criteria
If you want THIS to work in Conditional Formatting formulas:
Create another Named Range called THIS_CF and set the Refers to: to =THIS.
You can now use THIS_CF to refer to the current cell in Conditional Formatting formulas.
You can also use this approach to create other relative Named Ranges, such as THIS_COLUMN, THIS_ROW, ROW_ABOVE, COLUMN_LEFT, etc.
EDIT: the following is wrong, because Cell("width") returns the width of the last modified cell.
Cell("width") returns the width of the current cell, so you don't need a reference to the current cell. If you need one, though, cell("address") returns the address of the current cell, so if you need a reference to the current cell, use indirect(cell("address")). See the documentation: http://www.techonthenet.com/excel/formulas/cell.php
Reference to a cell that include this formula (self reference):
address(row();column())
E.g. getting the value of the cell above:
indirect(address(row()-1;column()))
Or what the OP asked:
=Cell(width;address(row();column()))

Resources