Trying to define a formula in excel - excel

I need to define a formula for a new column without dragging the cells such that the first row is zero and each subsequent row takes the value of the previous row and adds two to it. Is this possible to do using excel?

Related

Auto update adjacent cells?

I have a table in excel which is constantly having new rows added. I then have another sheet (lets call it results) which is referencing this table, and counting the values in each column.
Every time I add a new record/row to my table, the results sheet throws a bunch of errors in every cell that references the column. Because I'm using a fixed range in the formula to count the column, e.g. =SUM(A1:A10), I then need to manually click each cell in results and select 'include adjacent cells' to get the count to reflect the new data. I have loads of cells in this table and I'm adding data daily so this is a very long winded way of doing things.
I'm looking for a way that I can automatically update these cells, either by using a macro, or adjusting the formula so that it will automatically increase the range of the SUM when I add new data.
The best solution I've had so far was to simply define the range to include the row below my last piece of data (i.e. if A10 is my last record, the formula would be =SUM(A1:A11)). This works, and auto increments the formula when a new cell is added. However, if I delete the record from the table for any reason, the formula reverts to only including the range containing data.
In other words, this solution works, but only until I have to delete a record. Is there any better solution that can detect which rows are populated, and auto include them in the formula?
=SUMPRODUCT(INDEX('Sheet1!'A:A,1):INDEX('Sheet1!'A:A,LOOKUP(2,1/('Sheet1!'A:A<>""),ROW('Sheet1!'A:A))))
Using INDEX and ROW reference, deleting cells won't result in broken cell references. LOOKUP is used to calculate the last non-empty cell in column A. This will auto update.
Using SUMPRODUCT instead of SUM makes it an array formula and does not require older Excel versions to enter the formula with ctrl+shift+enter (because of the LOOKUP function)
In Office 365 you could use: =SUM(FILTER('Sheet1!'A:A,'Sheet1!'A:A<>""))

How do you change the default calculated column formula in an Excel list table?

I have a list with a column that did a lookup to another sheet in the workbook. The original formula looked like this: =VLOOKUP([#[Last Name]]&" "&[#[First Initial]],LookupLastF,9,FALSE).
Later the lookup column was moved, so I had to change the formula to lookup column 10 instead of 9: =VLOOKUP([#[Last Name]]&" "&[#[First Initial]],LookupLastF,10,FALSE). I had to manually copy the formula through the column, because there were exceptions -- i.e. some items overwrote the formula with manually entered values.
The problem is every time a new row is inserted into the table, the old formula is copied to the row instead of the corrected formula. So a default based on the original formula must still exist somewhere. How do I change it to the new formula?
You have to delete the content of the whole column and then (re-)apply the formula.
Mixing formula and static values within one column isn't a good idea.
Use three columns instead: calculated value, manual value, result value (where a formula shows the manual value if exists and if not the calculated value)

Set countif / countifs range to ONLY the last row in a range

I am trying to find the number of times a certain text string appears on the last inspection of a vehicle. The columns are areas to check, and each inspection is on a separate row. The range is D6:VG150 (the 150 is to allow for future inspections). The majority of cells are blank, either because I haven't used that row yet, or there was no fault found in that area during a previous inspection. The only column that will be filled is column A, which has the dates of inspection. I ONLY want results from the last inspection (to indicate current status on a fleet status worksheet). Even better would be to check the last filled cell in every column in that range, but that might be pushing it.
I have tried =COUNTIF(INDIRECT("'291'!$D$6:$VG"&INDEX(MAX((A:A<>"")*(ROW(A:A))),1)),"Schedule Repair"), but it returned the results from the entire range defined by the last range. I tried switching the first address of the range, $D$6, to $D&, but this returned a #REF! error.
I've tried to simplify your scenario. The screenshot below shows a table that starts in row 3 and extends to row 7. The formula counts how many cells in the last row of the table have the text "a". The formula is
=COUNTIF(INDEX(A:A,COUNTA(A:A)+2):INDEX(C:C,COUNTA(A:A)+2),"a")
You don't need Indirec. Index is a lot better. The first Index returns the cell A7. The second Index returns the cell C7. Using the colon as the operator will turn the two cells into a range that can then be used by Countif.
The last row is identified by counting all cells with text in column A, and then adjusting for the fact that there are empty rows above the table.
Oh, and by the way, if you use an Excel Table, you don't need to pre-fill formulas into empty rows. In an Excel Table all formulas are automatically applied to new rows.

Incrementing a column number within formula

Here is my formula:
{=MAX(ROW($1:$120)*(Table1[results1518]=1))}
so far I have done 1518 cells manually as indicated by the results#.
I have about 2000 more cells to go. The table is on one sheet and this formula in each cell on another.
I need to find a way to increment the results# from one cell down to the next cell below it and so on down the column on the second sheet.
I would make a helper column that listed all the result# you needed to cycle through. You can either use excel's auto fill ability or just add 1 to the value of cell in the row above. For example, A3=A2+1.
Next create a second helper column that returned a text value embeding that number. B2 would look something like this ="Table1[results"&A2&"]"
Finally, you can use Excel's indriect formula looks up the value specified by the second helper column. {=MAX(ROW($1:$120)*(INDIRECT(B2)=1))}
There are probabally more effecient methoods, but without knowing more about your setup, this is what I've got.

Fill dates array and add dummy variables

I have a column with dates called "dates". This column contain dates from 01.01.2010 to 31.12.2010. it should have about 365 rows, but it actually has only 231 rows, because the data was not collected regularly. The others are missing, and I'd like to fill the gaps in time.
How can I fill the array of this column with the missing dates? I want to add 134 rows in the place of the missing ones, filling in the missing dates.
Create another sheet and put all the dates in column A in your new sheet.
Make sure your sheet with the data in it has the data column all the way on the left (important for how Vlookup works)
In your new sheet, starting in Cell B2 put numbers 1 through however many columns you have in your data sheet along that top row.
In your new sheet use Vlookup to find all the rows where there are data
=VLOOKUP($A2,DataSheet!$A$1:$C$20,B1,FALSE)
Note that the lookup column ($A1) is locked in to the column but not the row and that the range you are looking up is locked in in all directions. This will allow you to drag to the right/down and fill everything in.
Drag to the right then drag all the way down.
there will be #N/As where you cannot find a match which you can suppress with either an IF statement of conditional formatting. But now you have a row for every day with blanks when there is not data!
I found a solution with a similar formula, but the result was the same.
First, I got the two columns of data—"date" and "values" in the columns A and B of the worksheet. Each consisted of 231 rows. Then, I spread a full array of dates—365 in a new column D. Finally, I used this formula:
=VLOOKUP(D2;$A$2:$B$1056;2;FALSE)
in C2 and obtained the only the values from column "values" corresponded to the new dates of column D.
Thanks for Brad's answer for directing me to the VLOOKUP function.

Resources