Excel: Dynamic Range excluding data/rows based on blanks in specific column - excel

Is there a way to remove from a dynamically generated range full rows based on whether there are blank cells on a specific column within the data that generates that dynamic range?
For example, from the data shown in below table:
I would need the data in the dynamic range to have only the below highlighted data/rows:
The newly created dynamic range would be used in a pivot table and I would like to it to group the dates (therefore the need to remove the blank rows within the range). Please also note that the original list will be updated regularly and would expand (vertically).

You can use the following:
=IFERROR(INDEX($B$2:$C$9,SMALL(IF($C$2:$C$9<>"",ROW($C$2:$C$9),9999999),ROW(A1))-1,COLUMN(A1)),"")
Array Formula Ctrl+Shift+Enter instead of just Enter and drag it in the same row and down
The formula checks if any value in the row is empty (Name or Birthday) to skip the row and look down it
Small will find the smallest row, Row(A1) will change to Row(A2) when drag it down
Column(A1) to copy the first column will become Column(B1) when you drag in the same row
Change B2:B9, C2:C9 and B2:C9 to correspond your Data(last row) and keep $ for fixed references

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)

Auto-copying values from adjacent cells to non-adjacent cells in excel

enter image description hereI need to make an auto-fill of values from adjacent cells in table to another non adjacent cells of another table, for example, I need to get the following:
Source values: C7,C8,C9 ...
Destination: G4, G7, G10 ...
Thanx
I'm curious about your use case for this. I also have questions:
Are the source and destination always ordered? Meaning the names appear in the same order in both? Are these both on the same sheet as in your example? Are there always 3 cells per name in the destination?
I can't think of a formula that would give the desired result, but here's an approach I would take.
Make sure your source values and destination are on separate sheets.
Create a helper column in your source value range numbering your rows of data 1...x
Copy cells 1...X and paste them directly below you last row of data two times. So you should see 1...X repeat twice.
Sort your helped column least to greatest - you should now have two empty rows between each row of data.
Copy the column of data you need and paste into your destination. Because of the empty rows it should preserve your spacing.
You can achieve this with VLOOKUP. Use this formula in the Destination table.
=VLOOKUP(G3,Source,2,FALSE)
G3 is the cell in which the name, e.g. "Mike", is written. In your sample this appears to be a merged cell. Note that in merged areas all cell content is always in the first cell. So, if G3:G5 are merged, nothing can be retrieved from G4 or G5 because all content is in G3.
Source is a named range of 3 rows and 2 columns, as per your example. If your source is a true table you can use its name. VLOOKUP requires that the name must be in the first column of the range you specify. You can also specify a hard range, if you don't like using names. In my example the Source range was $A$4:$B$6.
2 is the column in Source from which to return the result.
False specifies that you don't want an approximate match (but an exact one).
Of course, this method works in the direction opposite to your diagram. The formula is in H3 in my test sheet. This is because there are no formulas in Excel that write to cells they don't themselves occupy.

Structured references vs explicit cell references

I'm using Index-Match to match Full Names with head count in that party.
I have it working but it uses both the structured and explicit cell reference.
I can't figure out why when I add a new row in my table, the column with the index-match formula wont populate the last row.
This is the formula used:
=IFNA(INDEX(AA:AA,MATCH([#[Preferred Seating 1st Choice]],D:D,0)),"")
Column AA has the head count number and column D has the list of full names.
Preferred Seating is the column used to reference the search.
I looked around and can't seem to find why it wont fill in the last row after that rown info is entered.
I can only assume it has something to do with the mixed Explicit-structured cell/column references. Any help please.
Yes Excel may not automatically assume a formula needs to be automatically filled in an entire table column if it contains unusual references. Unless you have data outside the table, you should just refer to the columns in the table:
=IFNA(INDEX([Column AA Name],MATCH([#[Preferred Seating 1st Choice]],[Column D Name],0)),"")
These can be easily entered when editing the formula by selecting all cells in the source columns excluding the heading. The formula will always use the entire
source columns and the formula should automatically fill its own entire column.
You can also control whether a column automatically has its formula updated through a hidden property. The ability to change the behavior of the column only appears through the front end when you're making changes to the column.
After entering a formula in a column, Excel will either automatically fill the entire column and give you the option to turn off the automatic fill, or Excel will not automatically fill the entire column and give you the option to turn it on.
After entering a formula that isn't being filled, this icon will appear:
Click it and then select to Overwrite all cells in this column with this formula
Deleting a formula from one cell in a column that is being automatically filled will turn off the automatic fill. Double clicking a cell with a formula and pressing enter will give you the option to turn it on again.

Selecting a Specific Column of a Named Range for the SUMIF Function

I am trying to create a SUMIF function that dynamically adds up values in a specific column of a named range in my Excel sheet.
It is very easy to do this when there is no named range :
The formula picks out all the cells that contain "London" in their name and sums up the expenses related to London.
What I am trying to do is to use a named range called TripsData (A2:B5) and tell the SUMIF function to sum the entries in the column 2 of this range that meet the criterion of having London in their name.
How can I make this work without needing to create a second named range for column 2 and simply by telling Excel to look within the specified column of this named range? Index/Match only return one value so that doesn't work when there are several cells with London in their name.
Thanks for your help!
Use INDEX to refer to a specific column in the named range (it can refer to a whole column), like this
=SUMIF(TripsData,"*London*",INDEX(TripsData,,2))
You can do that without any named ranges at all, if you turn your data into an Excel Table object. Select any cell in the range or the whole range and click Insert > Table or hit Ctrl-T.
There will be a dialog that asks if your table has headers. Yours does. Now you can reference the table and its columns by their inherent names and build your formula like this:
=SUMIF(Table1[Expense],"*London*",Table1[Cost])
You can rename the table, of course, even after the formula is in place. When you click a cell in the table, there will be a new ribbon for commands that relate to tables only. It's a very powerful tool.
Any formulas, formatting etc. that apply to a whole table column will automatically carry over into new table rows. The table column reference will adjust automatically, too, of course, so you don't have to mess with dynamic range names or re-define what a named range applies to.
Note: the formula uses structured referencing instead of cell addresses. This option can be turned off by clicking File > Options > Formulas > tick or untick "Use table names in formulas"
You can use Chris' idea of Index(Table1,,Col#) with the named range "Table1" (without creating an Excel table Object if you don't want to for some reason) and STILL avoid the problem Applez mentions in the comment below Chris' idea. Applez warns that using a constant for a column number reference is dangerous if you later insert another column before that column in the named range. You will find that Excel does NOT auto increment the constant, so your formula breaks.
Applez is right..... so DON'T use a constant, use a column number "reference" instead of a constant. For example....
=SUMIF(TripsData,"*London*",INDEX(TripsData,,Column(B1)))
If you later insert a column between A and B, Excel WILL auto increment the reference Column(B1) to Column(C1). Just don't delete B1 or Row 1 or you will get a REF error. I usually use the the header/tile "cell" (in whatever row that is in) for that table column within the Column reference (as it is highly unlikely I will ever delete the header/title cell of column of a table unless I delete the entire column). In this particular example as it turn out, B1 "IS" the the title/header cell for that column in the data table. So that is what I used for the example.
Awesome formula, just in case anyone needs to use a similar approach to FILTER a range. I used this approach
pmGendHC is the range I wanted to filter (I expect a spilled range with my data) I needed a colum (column number 13) to be different than 0
=FILTER(pmGendHC,INDEX(pmGendHC,,13)<>0)

Resources