Dynamic ranges again - once more, with text strings - excel

I have a series of data sets (later to be used for populating comboboxes), and I've tried setting up dynamic ranges to list only the cells with useful data. In total, there are 160 rows of data, but the number of rows that will be populated will vary wildly.
In case it has a bearing on it (if the dynamic ranges detect "" as not blank, for example), the formula used to populate the cells in the range is
{=IF(ROW()-ROW(StartPort_NoBlanks)+1>ROWS(StartPort_Blanks)-COUNTBLANK(StartPort_Blanks),"",INDIRECT(ADDRESS(SMALL((IF(StartPort_Blanks<>"",ROW(StartPort_Blanks),ROW()+ROWS(StartPort_Blanks))),ROW()-ROW(StartPort_NoBlanks)+1),COLUMN(StartPort_Blanks),4)))}
(Based on #DennisWilliamson's answer at https://superuser.com/questions/189737/dynamically-updating-list-of-unique-column-entries-in-excel )
So far, I've tried both
='Saves_FilterLookups'!$C$3:INDEX('Saves_FilterLookups'!$C$3:$C$162, COUNTA('Saves_FilterLookups'!$C$3:$C$162))
and
=OFFSET('Saves_FilterLookups'!$C$3,0,0,COUNTA('Saves_FilterLookups'!$C:$C),1)
...but both give me the whole list, including the "blank" cells.
Most of the ranges contain text strings; one of the other ranges contains dates.
What am I missing? How do I fix it?
EDIT: To give a bit of context, here's a bit of the list. The full list contains entries scattered along its length, duplicates are removed into the second column, and they're all consolidated into a single block in the third column. They're then populated into the combobox in the userform, but all the blanks are coming in too...

Here is a potential solution for you...the caveat is the cell above the list needs to be blank
=IFERROR(INDEX($A$2:$A$13,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$13),0,0),0)),"")
That will generate the list all in one step sorted and blanks removed.
I believe your COUNTA is your culprit. COUNTA will count all cells with something in them...and unfortunately "" is something. So you will need to eliminate the count of "". so I added a -COUNTIF and assumed the same range your were counting before. The worksheet name is not required if it is all being done on the same worksheet.
=OFFSET('Saves_FilterLookups'!$C$3,0,0,COUNTA('Saves_FilterLookups'!$C$3:$C$162)-COUNTIF('Saves_FilterLookups'!$C$3:$C$162,""),1)

Related

Dynamic named range including rows and columns

Little help needed here with excel dynamic named ranges.
I know how to make a dynamic named range that adjusts row height depending on the size of the range (no. rows with data in):
=OFFSET(Helper!$DJ$3,0,0,SUM(--(Helper!$DJ$3:$DJ$30<>"")))
However I find myself working with a large(ish) range of data across multiple columns - about 100 - and I REALLY want to avoid making 100 named ranges.
It must be possible to create a single named range that references the whole data set (DJ3:HE30) and the formula dynamically chooses which column to look at and (as before) chooses how many rows to return in that specific column.
The closest I've got is this:
=OFFSET(Helper!$DJ$3,0,0,SUM(--(Helper!$DJ$3:$DJ$30<>"")),SUM(--(Helper!$DJ$3:$HE$3<>"")))
But this just goes to the last column with data in (which makes sense really as it's doing the same thing with columns as it is with rows).
I'm assuming I need to tweak the starting point of the offset ref and somehow pass that column to the rest of the formula.
These named ranges are going to be used for drop-downs so the first drop-down will be the criteria that needs to be passed on to the second drop-down (that will utilize this new funky named range).
For example - if my first drop-down uses criteria 1,2,3 etc - my second drop-down would need to display results like this:
Option 1 = A,B,C
Option 2 = D,E,F
Option 3 = G,H,I
So the lists containing the letters in this example are all in individual columns, so the dynamic range needs to identify which column to use to pull the right list.
Also, with the number of columns I think I need to make this an INDEX rather than an OFFSET.
Can anyone point me in the right direction?
Thanks in advance, much appreciated!
It looks like I have managed to solve this one myself.
What I have done is create 2 named ranges as helper cells - Range_Start and Range_End. These ranges are single cells that contain an ADDRESS ref using MATCH to pick out the start and end of the column I need.
I then pass these named ranges to the formula I showed in my question but using INDIRECT to convert the cells to addresses:
=INDIRECT(Range_Start):INDEX(INDIRECT(Range_Start):INDIRECT(Range_End),COUNTA(INDIRECT(Range_Start):INDIRECT(Range_End)))
Works like a dream :-)

Determine if an Excel column has any value?

Question: with or without VBA, how can we determine if a specific column (say column "A") has any value in any cell in it?
Remarks: Question is about finding out whether a column (with a header, say, LastName) has any value (text/number) in it. The search is not on any specific value.
Reason for the Question:
We have more than a 1GB Excel file with about 1 million rows and several columns with headings. When we scroll down to one of the columns the column looks empty. But since the file has more than 1 million rows, we just keep scrolling down with no text found. But it is taking too much time to keep scrolling down to determine if there is any value inside the column. And, we may have to do the same for some other columns that do seem empty. So, we are looking for a better way to do it.
The issue is somewhat related to what's described in item 4 of this article: Tackling the most common errors when
trying to import a CSV
Consider Conditional Formatting
Apply to Header Row only
Select header row cells containing headers (not the whole row)
Add CF Formula, and set format to suit your preference
=COUNTA(A:A)>1
Highlights headers in columns that contain data. To highlight columns headers that don't contain data, use
=COUNTA(A:A)<=1
Note: this will consider cells that contain an empty string (eg from a formula) to contain data. If you want to consider those cells as empty, use
=COUNTBLANK(A:A)=ROWS(A:A)-1

How to Isolate Rows of a Table Given One Column Using Two Variables

So I want to isolate all of the rows that are labeled 'Good' from all the rows that are labeled "bad".
I've tried to use the 'sort and filter' tool in excel, but this hasn't worked, I think due to the presence of the index table, which I've used to generate my formulas.
Here are the formulas being used to obtain a unique number for each row, which I then use to determine whether a value is "good" or "bad".
For reference, not all the boxes in the spreadsheet that are green are labeled 'good'.
This can be done by using an if statement and matching to the relevant number in the table, then printing the corresponding column data. This will need to be repeated for each column of data you want to use. An example of the code is given below;
=IF(ISNUMBER(MATCH(A2,AB:AB,0)),AG:AG,"No Data")

Show nth value in a list that matches specific criteria [EXCEL]

I would like to find the nth value in a list that matches specific criteria and have those values printed in separate places in separate worksheets.
More specifically I have a list of invoice numbers either beginning with a number or with PF and I want the first (or second, third etc) value beginning with PF to show on the Proforma Invoice worksheet, and the first (or second, third etc) value beginning with a number to show on the Invoice worksheet.
At the moment I have a selection of invoice numbers like so:
Invoice #
PF17-0982
43256
65342
96038
PF16-0934
10293
And I would like to print the nth value on this list matching the criteria I give, so either beginning in a number or beginning in PF, in a separate worksheet.
Initially I tried
=IF(LEFT('Top Sheet'!S5)="P",'Top Sheet'!S5,"")
which works to find the number beginning with PF but obviously only for the first cell in the list.
I also have
=IF(ISNUMBER(LEFT('Top Sheet'!S5)*1),'Top Sheet'!S5,"")
Which again works wonderfully for the first value in the list but not for much else.
So, naturally, I googled and tried using INDEX and MATCH and SEARCH functions as found here https://exceljet.net/formula/get-first-match-cell-contains but I don't want the output to be another list dependant on only one of the values in the invoice number list. However I don't mind having an intermediate list (e.g. list of TRUE and FALSE values) which will ultimately lead to me having a single output. I have this list at the moment which was done using:
=SUMPRODUCT(--ISNUMBER(SEARCH({"PF"},'Top Sheet'!S5)))>0
And that brings me here, I've tried various variations of the above techniques and failed hopelessly. I either get an error of some description or just TRUE and FALSE values. I hope this makes sense.
Another formula approach, with which you can enter the formula normally, is to use the AGGREGATE function to determine the row number within the array of invoices. With the SMALL operator, you can work on an array, ignore errors, and return multiple values.
If Invoices is a named range containing your list of invoices, then:
For invoices starting with PF
=IFERROR(INDEX(Invoices,AGGREGATE(15,6, 1/(LEFT(Invoices,2)="PF")*ROW(Invoices)-MIN(ROW(Invoices))+1,ROWS($1:1))),"")
For invoices starting with a digit
=IFERROR(INDEX(Invoices,AGGREGATE(15,6,1/ISNUMBER(-LEFT(Invoices,1)*ROW(Invoices))*ROW(Invoices)-MIN(ROW(Invoices))+1,ROWS($1:1))),"")
For either of these formulas, enter in some cell and fill down until the formula returns blanks. The ROWS... argument will increment and return the appropriate k for the SMALL function.
Another method would be to use a simple Filter, then copy/paste the visible cells to where you want.
Or you could use the Advanced Filter, which has a built-in method to paste the results to another location.
In order to extract multiple items from a list you can use the INDEX function with SMALL to create an array formula.
=IFERROR(INDEX($B$4:$B$9,SMALL(IF((ISNUMBER($B$4:$B$9)),ROW($B$4:$B$9)-3),ROW(1:1)),1),"")
IMPORTANT: use CTRL+SHIFT+ENTER when entering this formula to make it an array formula.
This formula takes the first numeric value from your list. If the formula is changed to ROW(2:2) it would select the 2nd numeric value from the list and you can autofill the formula down to extract as many as you like.
It's quite a complicated formula to follow but you first index a range "INDEX(B4:B9" then use SMALL with an if statement "(ISNUMBER(B4:B9)". Then define the first row of the source data "ROW(B4:B9)-3)" the minus 3 is because it's 3 rows from the top. Next the row that matches your criteria that you want to extract "ROW(1:1)" and last the column that contains the value that you want "),1"
I'm not the best person to explain this formula but there are some good tutorials online.
PivotTable alternative:
(optional) select the range of cells including the header "Invoice #" cell
Insert tab > PivotTable
make sure the header cell is included in the Table/Range: field
select Existing Worksheet and the Location range where you want the filtered list
on the PivotTable Field List that shows up on the right check the Invoice # field
on the sheet, in the Row Labels cell click on the triangle filter button and select Label Filters > Begins With... > PF
(optional) in the Design tab click Grand Totals > Off for Rows and Columns, uncheck Column Headers, and rename the Row Labels cell text if needed
For the numbers, you can copy the PivotTable and change the Label Filter to Less Than... > A
Whenever the source Invoice # range changes, you can click Refresh All on the Data tab for the PivotTables to refresh.

How to sanitize a collated column with text and numeric data to make it uniform for easy analysis in excel 2007

I have 3 column heads and I wanted to collate it with 3 similar heads from another sheets. 10% at an average from each of the 6 columns is blank, I have to map the data based on these 3 columns to other data and I need them to be sanitized. So there are the blanks and then there are some cells which have text like 208110185726A570-14. Please help.
Haven't heard back from the comment above, but I'll have a go at this anyway (and will be using assumptions that may be incorrect):
Given that you have included the tag vlookup, I'm assuming that you want to build a table that uses the leftmost column as an index of unique values to conduct a VLOOKUP. If that's the case, I don't see any way around blank cells in the leftmost columns in the two sheets, other than saying that the ensuing VLOOKUP would skip over any row that had a blank leftmost cell.
If you can live with that, the way I would go about it is pretty simple:
Copy the columns from one group (omitting the header row) and paste them to the end of other group. Again, since you have mentioned VLOOKUP, I'm assuming that keeping the cells in the rows next to each other is the goal (i.e. you can't remove the blanks in the columns because otherwise that would mess up the horizontal integrity of the cell relationships).
Do your VLOOKUP. Again, I'm assuming unique values in the leftmost column. This assumption is important, because it will make a difference to the decisions you make about what type of VLOOKUP you use (range vs. exact match) and what value is returned. For example, if you use exact match and there are repeating values, it will return the 1st match it finds.
Again, the assumptions might be wrong, but the question is a little unclear.

Resources