How do I prevent Excel from automatically replicating formulas in tables? - excel

I'm using Excel 2016. I have a table with headers and when I plug in a formula, Excel is automatically replicating the formula to all other cells in the column. While that would normally be fine, it's wrongly calculating the table headers. I thought I could just change the top row to exclude the header but Excel updates the rest of the column which I don't want.
I would like to either turn this automatic formula replication feature off or figure out a way to customize the formula in the top row so it doesn't calculate the header value.
Here's the formula I'm using and I didn't do anything special with the table outside of add a 'Totals' row:
=SUM(B2+C1-D2)

You can stop creating calculated columns. The option to automatically fill formulas to create calculated columns in an Excel table is on by default. If you don’t want Excel to create calculated columns when you enter formulas in table columns, you can turn the option to fill formulas off. If you don’t want to turn the option off, but don’t always want to create calculated columns as you work in a table, you can stop calculated columns from being created automatically.
Turn calculated columns on or off
1) On the File tab, click Options.
2) Click Proofing.
3) Under AutoCorrect options, click AutoCorrect Options.
4) Click the AutoFormat As You Type tab.
5) Under Automatically as you work, select or clear the Fill formulas in tables to create calculated columns check box to turn this option on or off.
Stop creating calculated columns automatically
After entering the first formula in a table column, click the AutoCorrect Options button that is displayed, and then click Stop Automatically Creating Calculated Columns.

In Excel 2016/365 you can also change a cell you want, let it auto-populate the rest of the column, then Ctrl+Z, this will undo auto-populate but keep the new formula/text you just changed in that one cell.

First, why do you wrap a simple formula into a SUM function? I always wonder why people do that when it's much shorter to write =B2+C1-D2 instead.
Second, if you used the true capabilities of SUM() then text, i.e. your column header, would be ignored instead of throwing an error. The + and - operators don't tolerate text, be it in a table or not. You could rewrite your formula to be
=Sum(B2,C1,D2*-1)
Third, be aware that cell referencing like that will behave erratically when you insert rows into the existing table (between existing rows). The row references will be off for anything below the inserted row and you will need to manually copy down the formula again to get correct results.
In order to get a formula that does not require adjusting, you may want to use structured referencing, where each row has exactly the same formula, instead of cell references, where row references are adjusted in each row. A possible formula for this would be (if your columns are labelled data1, data2 and data3 for columns B, C and D):
=SUM([#data1],OFFSET([#data2],-1,0),[#data3]*-1)
To get the data from the row above, Offset() is used on the cell in the current row (using the # sign), with a negative row offset. Keep in mind that Offset is volatile, which may slow down very large datasets.

Adjusting AutoCorrect options is not optimal. You can do it on a col by col basis by:
let the column autopopulate your formula
delete any number of values in the autocalculated column (just one will do the trick).
adjust formulas in the column as you wish
Only able to test in Excel 2013.

May be a little late to open this query - but a couple of points:
formula replication does not work if there are already different formula in the column - may need 3 different formula before Excel says it cannot guess which formula to replicate
a solution could be to add 2 dummy rows at the top which will then prevent the replication - the benefit of this is that you are not disabling replication for any other tables that may be in the workbook; and I'm not sure if the setting may also inadvertently be copied to other new workbooks you create whilst you have the first workbook open
finally, the old chestnut that =A1+B2 etc creates an error if A1 or B2 are not numeric; whereas =sum(A1,B2) works differently in that text will be ignored and effectively treated as zero

If your reference has letters in the middle these technics won't work. To add a zero before the reference in that case, create a new column next to it, add "0" to all the cells next to the references, add another column and use the function "concontenate" or whatever between the "0" cell and the one with the reference.
Not only that, the =len function will correctly tell you the # of digits on references with letters in the middle (because excel does not view them as numbers per se, but rather text/general format) while on other references with 0s added before them with formatting this doesn't happen.
Eg: 012345 =len gives 5 digits / 01A345 =len gives 6 digits

Related

How to count unique column data in an excel sheet

I am using excel sheet and i have data column as shown below:
As we can see that some of the names are duplicate or appeared twice. My question is how can count unique name records or rows associated with each name for summary column.
Out put i am looking for is shown below:
Not sure which formula to use as count is counting all of that data i.e. '7' in this case. How can i use count or any other function to count unique records as shown above?
You can do what you're after with a pivot table.
Click the Insert tab then select "Recommended Pivot Tables".
A window will open up prompting you to select the data range. I recommend using a named range for your list and referencing that, but you can just highlight the list directly if you want.
Once the data range is selected, click "Ok" and new window will open with exactly what you want. A unique values list and a "Count of Column1". It is the default of the recommended pivot tables.
I outlined this because it's easy and fast, but it's important to understand you can make this pivot table yourself from scratch if you learn about pivot tables in general. Pivot tables are often overlooked in Excel as an option.
Lastly, you could get really advanced with Excel Power Queries. Just Google "Excel Power query" and you will be shown all kinds of information on them. They are a close second place in power to manipulate Excel data short of using VBA.
Good luck!
CountA(Unique(D2:D8,,False)) = 5 [Count(Unique(D2:D8)) is the same as False is the default.]
CountA(Unique(D2:D8,,True)) = 3 (once and only once)
Note: the Unique function was released in late 2019 to Office 365. So if you want to use this check your version, not present in 1908, present in 2006.
Edit: It's actually in 2002, I just updated my 1908 machine.
HTH
If names duplicates are removed the following formula can be used: =COUNTIF(B:B,F2)
If duplicates must be removed by formula, MATCH (searches for a specified item in a range of cells, and then returns the relative position of that item in the range.) and SMALL (Returns the k-th smallest value in a data set.) functions can be used as shown.
C$1048576 is used to reference last row number for a big list case.
formulas:
Column A, names sequence
Colunm B, names
Column C, formula =MATCH(B2,B:B,0)
Column D, formula =IF(COUNTIF(C2:$C$1048576,C2)=1,C2,"")
Column E, formula =SMALL(D:D,A2)
Column F, formula =VLOOKUP(E2,A:B,2,0)
Column G, formula =COUNTIF(B:B,F2)
For anyone like me without O265's lovely Unique & Filter Functions, and who doesnt want to use a pivot table, and there are many ways to do this, but this i have just done this in normal excel.
List of data in Column H, Formula in column O3. Drag down. Highlights your distinct and unique values from H.
=IF(COUNTIF(H:H,H28)=1,"U - "&COUNTIF(H:H,H28),IF(COUNTIF(H$1:H27,H28)=1,"U - "&COUNTIF(H:H,H28),"-"))
Formula is short. You can just do this and drag down. Apply the same principal to your worksheet data wherever it is.
=IF(COUNTIF(H:H,H3)=1,"U",IF(COUNTIF(H$1:H2,H3)=1,"U","-"))
Similarly, you can just use this formula here (credit goes to this source for this one):
=(COUNTIF($H$1:$H1,$H1)=1)+0
Id like to point out that the above formula is a better formula than mine. It highlights with a "1" (or with a tweak, the value of your choice) the first time any value is seen/spotted on any given list, whether duplicate or unique.
Whereas mine is a bit "more random" when picking up the "unique and distict" values.
Mine gets there in the end, but Extend Office's gets there first, as I think is proper (getting the first time a unqique distict value is spotted/occurs.).
Formula in K5 =IF((COUNTIF($H$5:$H5,$H5)=1)+0=1,"UNIQUE DIST","") and drag down...
You could append/add a normal basic countif after the results to show how many actual times the given value appears if you wanted. :
=IF((COUNTIF($H$5:$H5,$H5)=1)+0=1,"UNIQUE DIST","")&" - "&COUNTIF(H:H,H5)

Shortcut for adding product of two cells along a table row?

I have a cell which wants to be a total of a table row multiplied by reference cells above the table. For example, $F$2 * F4 + $G$2 * G4 + $H$2 * H4. The table extends for about 100 columns which is why I'd like an automatic way to do this (also in case the table ever expands).
To clarify, I know my example works, but I want an automatic way (where I can specify two rows, like f2:bz2 as the 'reference' row and f4:bz4 as the other row) to do this. Since the second row is in a table, it would be ideal if the solution allowed for adding another column to the table too.
If you want something that expands automatically with your table, may be this:
=SUMPRODUCT(Table1[#]*OFFSET(Table1[#Headers],-1,0))
which assumes that your fixed coefficients are one row above the headers of the table. But it also assumes that you're entering the formula on the same row that you want to process. Unfortunately, if you have the formula to process a different row, you will need to wotk with normal ranges, such as the formula suggested by #pnuts in the comments section. But then it will not scale automatically as your table grows (unless you expand it by insertion of columns).
If you use:
=SUMPRODUCT(($F$2:$XFD$2)*(F4:XFD4))
You will both:
avoid REALLY long formulas
have a formula that automatically incorporates new columns of data as you add them

Excel apply formula after pasting table

Is there a way to create an excel template, which automatically applies a formula if a certain column is inserted? The use case would be:
User copies a table from a desktop program (CSV or Tab separated)
Pastes the table into the excel template
Somehow the column's header gets matched (header's name is fixed)
Multiply the column values with a fixed value (like 1.25)
The problem is that the column could be in different indexes and the formula should apply to all the rows, not just fixed ones, but my main problem is how can I get a copy-paste event and find the column.
Edit.: I can only do this with VBA (never used it before)?
Assuming the column header is constant you could insert a table with "dummy" headers and a calculated column using the header name as a reference
In the example I have put a formula in the Calc column. I've put the Calc in column G assuming your maximum import columns are six and because it's good practice to do your calculations from left to right.
You could move the Calc to column A and reduce the "dummy" columns to just 1 with whatever your desired heading is.
To make a template, delete row 3 and clear out the dummy data, just leaving the calculation(s) and save as a .xltx in your profile template folder (wherever that may be in your versions of Windows/Office).
When you paste in your import data the table will extend down and copy the formula(s) automatically. If you have moved your calculation(s) to the left of the table, the table will resize to the right to accommodate all your imported columns.
While the MyHeader column in your template may be over-written, if it can still be found in `Table2[#Headers] the formula will still work.

How to automate a spreadsheet so that changing a value in one cell allows that entire row to appear in a separate tab of the worksheet?

Say I have a spreadsheet, as shown below:
Is there some kind of tool, add-in or formula, that would allow me to take all of the rows that are in 'July', and put them in a table in a separate tab:
In such a way that if I changed say 'COA' (the first row in the first picture) from January to July, it would automatically update the separate table to include this?
(Or at least be updateable with a click of a button or by refreshing)
My boss has asked me to see if this is possible, and I have no idea of how to go about it.
Thanks
It is possible.
In order to extract multiple items from a list you can use the INDEX function with SMALL to create an array formula.
Try the formula below. It assumes that the first column is A and column F contains the months.
=IFERROR(INDEX($A$2:$F$300,SMALL(IF(($F$2:$F$300="July"),ROW($A$2:$F$300)-1),ROW(1:1)),1),"")
IMPORTANT: use CTRL+SHIFT+ENTER when entering this formula to make it an array formula. You then need to auto fill down to get all the July records. This formula pulls data from column 1 (that's the last 1 in the formula). If your code in column 1 is unique to each row you can use a VLOOKUP to get the other columns. If it's not then you can copy the formula to the next column. And change the 1 at the end to 2..3 etc.
Instead of putting July in the formula you can reference a cell that contains July and then duplicate the sheet and change the cell to August or simply change the cell whenever you like to see data for different months.
It's not an easy formula to follow but it does work.
You could try doing a Pivot table with all the columns expect month in the rows section, using tabular view, no subtotals, and repeat item labels. Then put month in the filter section. Then you can update the pivot table by right click refresh or by clicking the refresh all on the data tab

How to automatically enforce a formula in cells for a newly created row?

I have a worksheet used for estimation where some columns have a formula, most importantly Column(A) has a formula =ROW() which I used as an ID for that estimate (row item) and Column(I) is a total (=SUM(E2:H2)) of all the estimates in that row.
When a user inserts a new row (a new estimate) I need to ensure the new row already have the required formulas in them, I do not want to have the user need to drag the formula from the cells above it (this is not being used by Excel-savy people).
Also, this should only be done to a specific range of rows (I do not want to see an ID/Total for Row750 if it is not used), there needs to be a way to tell it to stop at a specific point (for example I have a row(13) there B13="TOTAL" and C13=SUM of totals (overall total) and this should be the last row, so if the user interests a new row it would be above this one, etc...
Any help/hints/ideas would be much appreciated.
You could use the 'Tables' feature. In Excel 2003 it was called 'Lists'. I'm not sure where to find this feature in 2010.
Ex:
Define a range as being a list table. I used the ROW() function to autonumber the rows. Here's how it looks:
It doesn't overcome the problem that Tim mentioned, but I file that under "not a problem". I actually prefer dynamic autonumbering. When you insert a row, the autonumber changes automatically:
And when you delete a row, the autonumber adjusts:
The best part is that any formulas in the list table will auto-fill down. Besides the ROW formula, I added a SUM formula in column C, then added a new record:
As far as stopping at some point, you will need to move your formulas to another column. The list will continue down and won't stop simply because you have a formula there. You would need to right-click the list table, choose "Insert » Row" in order to keep your formulas in the same columns as the list table.

Resources