I have an Excel file with two worksheets.
In worksheet 1, I have an Excel table with three columns.
In worksheet 2, I want to perform some calculations on the Excel table.
Now, in F5, the formula is =NB.SI(mytab[col1];F4).
Now I want to duplicate the formula on the cells from left to right, by clicking on the + sign
in the bottom right corner of F5 and "spreading" it from left to right.
The actual result is that the range mytab[col1] is changing to the others range (mytab[col2],mytab[col3],..)
To obtain the desired result, I had to copy and paste the formula so mytab[col1] can't change.
Is there a way to lock the range by F4 ?
Actually this is a reduced example, in real world I have about 27 values rather than 5.
Many thanks in advance.
For a table range, you can make ranges absolute like this: =NB.SI(mytab[[col2]:[col2]])
The images you posted aren't much good - the 2nd one doesn't show the formula.
If you want to make the reference to col1 from mytab absolute, i.e. it won't change as you drag the formula across you can use mytab[#col1:col1].
=NB.SI(mytab[#col1:col1];F4)
Related
I have an excel file with times in column D, F and H. I want to color the cell with the lowest time.
I have tried several things from the Conditional Formatting but it does not work.
Any suggestions how to solve this?
What you want to do cannot be done with the built-in simple formats. You need to create a rule that uses a formula.
Before you do that, select the range in the worksheet. Then click New Rule > Use a formula to determine. In the screenshot that is the range from C3 to H5.
In the formula box, use a formula like this
=C3=MIN($C$3:$H$5)
Important!! The reference to C3 is relative to the current cell. There are no $ signs in that reference, so each cell in the range will be evaluated individually. You should use the cell at the top left of your selection. The range reference inside the MIN() function is absolute, using $ signs.
If you want to highlight the smallest value in each column, you need to create separate rules, one for each column.
When I have a formula in a cell (the list is about 8,000 long, I go to try and sort it from most to least, however when I do this it will not sort, I believe it is because there is a formula in the cell, is doing it the normal way of clicking on the cell(s) and using the ribbon. Is there a special way of doing it when a formula is involved?
Thanks
Yes, by using absolute reference in your formulas, i.e. "$" for the rows. Since you are changing the order of the rows when you filter you need to make the reference static.
The table below is sorted by "Largest to smallest."
Another solution could be to copy the area and paste in a new sheet as "values"
In Excel 2007 I use the following formula to refer to cells in other worksheets in the same workbook:
=INDIRECT($B$2&"!A9")
B2 contains the name of the worksheet containing the target cells (I want to turn this into a template, so I don't enter the name into the formula). The formula works, but I want to use this same formula over multiple rows (A10, A11, A12 [...] A1000). I am using this same code over multiple rows but with different fields (B9, C9 and so on), with a variety of different content types (data, number, text).
An alternate version of the formula is as follows:
='Worksheetname'!A9
But again, this requires hard-coding the name of the worksheet, which is not desirable for me.
Because of the sheer volume of the rows manual editing is not an option: is there any way to alter this formula so I can easily use it over multiple rows? Preferably without the use of VBA, but that is not a requirement.
If your records are located in the same cells in both worksheets, then you can use something like following:
=INDIRECT($B$2&"!"&ADDRESS(ROW();COLUMN()))
IF now, then you can easily offset them using given ADDRESS function
P.S. Please be aware with INDIRECT function that it slows down calculation performance on your workbook (few functions are OK, but if you have 10,000 of them then you might see some delay)
If you want to use the same formulas for several columns as well you could include something like this:
=INDIRECT("'"&$B$2&"'!"&ADDRESS(MATCH($B4;INDIRECT(CONCATENATE ($B$2;"!";"B:B"));0);MATCH(B$3;INDIRECT(CONCATENATE($D$2;"!";"A3:AR3"));0)))
B2=reference to sheet name
B4=first row for your data
B3=Column header
For those who want to pull all the same column of data from multiple sheet that have the same layout (and have each cell linked), it took me hours to work it out, but actually can be solved with a relatively simple way:
=OFFSET(INDIRECT("'"&G$2&"'!l7"),$A6,0,1,1)
The Indirect part take you to the right sheet and right cell, G2, H2 ... has the Sheet names (be mindful of sheet name with space, you will need to use ' ', which is the case for my workbook), and L7 cell of that sheet, and I want L8, L9, ----L200 all being pulled through;
Offset help you navigate the range of rows, A6 is an additional numbering row I added to move to the right row in each sheet.
Hope it help!
Say I have this line in a macro:
Sheets("sheet1").Range("A1").Value = Sheets("sheet2").Range("A5").Value
How can I programatically (only via VBA) make it so that if rows or columns are inserted in sheet 1 between A1 and A2, A1, B2, it will not mess up since the rows numbers are changed?
The standard way of avoiding these sort of problems is to use Named ranges.
If A1 is and important place for a result it could be called "myResult" and if A5 is an important place for input then it could be called "myInput". Your code would then change to:
Sheets("sheet1").Range("myResult").Value = Sheets("sheet2").Range("myInput").Value
Doesn't matter how many columns or rows you now insert the above code will always find the same cells.
Or am I misinterpreting the question?
If these ranges A1 and A5 are actually always in the same relative position in a table e.g. bottom right hand corner, then the solution would be different.
I've got a spreadsheet that has a bunch of cells with simple formulas that look like: =(column letter)(row)/(column letter)(row). =E92/E77 for example. There are 6 rows of 12 of these formulas, and I want to change the divisor row (77 in example) to a different row for each of them. Now I know that I can just change the first one in each of the 6 rows and drag the formula across the remaining columns for each row.
I want to know is there a quicker way to change a cell reference (terminology?) for many cells?
I hope the question is clear enough, if it is not then say so and I will try to clarify.
Thanks!
A good idea is to name your cells (or even ranges), using the textbox left of the formula bar. You know, the one with with current cell coordinates. Just select the cell, type in the name, and press Enter.
Then, you use that name instead of the cell coordinates in your formulas. If you ever need to change it, you can use the Name Manager and change the name to point