Excel 2007: Data Validation list with filtered data - excel-2007

I would like to have a Validation List in cell D5 on Sheet1. The items in this list should be dynamically based on a table on Sheet2, but I only need the ones where Column2 is TRUE. Below is an example of my table on Sheet2:
Column1 | Column2
Item1 | TRUE
Item2 | TRUE
Item3 | FALSE
Item4 | TRUE
Based on the tabel above the Validation List in cell D5 on Sheet1 should only contain Item1, Item2 and Item4. Is this somehow possible (preferably without using VBA)?
I know I can create dynamic Named Ranges, but I don't know how to filter them, based on another column.

You probably want to create an index to filter out the false.
Easiest way would be to flip your columns, or make column 3 a copy of column 1, then use a formula like.
Column1 | Column2 | Column3
Item1 | TRUE | Item1
Item2 | TRUE | Item2
Item3 | FALSE | Item3
Item4 | TRUE | Item4
{=INDEX($B$1:$C$100,SMALL(IF($B$1:$C$100="TRUE",ROW($B$1:$C$100)-ROW($B$1)+1,ROW($C$100)+1),1),2)}
{=INDEX($B$1:$B$100,SMALL(IF($B$1:$C$100="TRUE",ROW($B$1:$C$100)-ROW($C$1)+1,ROW($C$100)+1),2),2)}
Those would be your first 2 fields, they create an index that gives you the 1st and 2nd result with TRUE.
The 2nd number at the end of the formula determines which item in the list.
when you enter the formula, you can't just type it in with the { }, leave those off and press ctrl+shift+enter to complete the formula and it will put them in for you, this is vital to creating an index formula.
Once you have the index created, it will update based on the true/false values. If you then use that range in a data validation dropdown, it will update with the index.

Related

Replace rows from table that has specific value of multiple columns?

Let's say I have a table like this called MyTable.
| Column A | Column B || Column C | Column D |
| -------- | -------- || -------- | -------- |
| Cell 1 | Cell 2 || Cell 3 | Cell 4 |
| Cell 5 | Cell 6 || Cell 7 | Cell 8 |
And now I am inserting new row into this table that has format like this:
| Cell 1 | Cell 2 || Cell 3 | Cell Something else |.
What I want to do is replace an existing row from MyTable if the row I am inserting has the same value of the first 3 columns of MyTable (column A, column B, column C). As my real table has 250+ columns and
I want to replace rows if they have same value of 5 columns, I don't think INSERT ON CONFLICT UPDATE is good for this. In my opinion, it would be best to DELETE rows that need to be replaced and just INSERT new ones, but I don't know how to write that query.
I was thinking of INSERT ON CONFLICT UPDATE but firstly: I don't think I can specify more columns in ON CONFLICT part, and secondly: I think that I would need to specify 250 columns in UPDATE part, so that also doesn't work for me.
There is no problem specifying multiple columns in the on conflict clause, you just need a unique constraint on those columns. (see demo). As far as you having 250 columns (a highly questionable design, but another question altogether) you have no way around it you must list every column you want updated.

More efficient way to compare records in DataGridView

I have a DataGridView (bound to a DataTable) which has data something like this:
| Col1 | Col2 |
|------|------|
| 1 | Y |
| 1 | N |
| 2 | Y |
What I need to do is find where a duplicated value in Col1 has a different value in Col2.
At the moment I do a nested For Each loop to compare each row in the DataGridView with every row in the DataGridView but this is, obviously, very slow and scales horribly... Cost is somewhere around n^n.
Is there a better way I can do this without having to loop over the whole DataGridview for every record?
I want to filter the DataGridView to only show records where there is a mismatch between records of value in Col1 and values in Col2 (in this case, '1' should be shown because it contains both 'Y' and 'N').

Comparing Column1 to Column 2 and writing to Column3 if match

I have an excel worksheet linked to a SQL query in column [Raw Data]. After adding a few columns with formulas to clean up the raw data, i need to find if the value in column [ProcDataQ] exists in column [ProcDataO], all columns comprise to make Table1.
ProcDataQ | ProcDataO | Stat
--------- | --------- | ----
C1234 | C7126 | Ordered
C8372 | C6152 | No Order
C7126 | C1234 | Ordered
I am able to do this with the below formula but i have more than 20,000 records and it takes on or around 30 seconds to load or refresh the table and i figured i could speed this up using a little vba that I'll trigger to run on the query refresh.
=IF(AND(LEFT([#[Raw Data]],1)="q", (NOT(ISERROR(MATCH([#ProcDataQ],[ProcDataO], 0))))),"Ordered", "No Order Placed")
fyi, i am running excel 2010 on PC.
Just use an IF and COUNTIF statement:
=IF(COUNTIF(range, item to look up)>0,"Ordered","Not ordered")

Extracting rows based on a cell value on dynamic data

I am trying to extract rows from an Excel sheet based on the cell value. Consider below example:
Sheet 1 columns:
Group | Question | Option1 | Option2 | Answer
Sheet 2 columns:
Question | Option1 | Option2 | Answer
As demonstrated above, I'm filtering the rows from Sheet 1 based on the Group and populating the data in a separate Excel sheet.
Issue: If data is added in Sheet 1, how can it reflect in Sheet 2 simultaneously.

Reference lookup side column values based on cell value

I've got two worksheets, (a) contains rows which need to be dynamically updated based on a cell (ID), (b) contains over 10k product data by columns.
How do I achieve worksheet (a) to lookup data from worksheet (b) and based on the ID it picks up data from nearby columns. So when I change the ID to eg. 02 it will automatically populate above rows.
Worksheet A
Name
Price
Qty
ID
Worksheet B
ID | Name | Price | Qty
01 | Screw| 0.5 | 500
02 | Nail | 0.4 | 1000
03 | Cap | 0.2 | 800
Yes vlookup will work.
in each cell (except ID) you will need to put this formula:
=VLOOKUP(B1,WORKSHEETB!A1:D4,2,FALSE)
where "B1" is your ID and used to reference you table in worksheet B.
WORKSHEETB!A1:D4 is your table array (your table in worksheetB).
"2" is the column that you are referencing. Example Name is found in column 2 of that table array (doesn't matter where the table is located within the sheet name will always be column 2)
see images attached:
Assuming Name is in Cell A1, Price is in Cell A2, Qty is in Cell A3 and ID is in Cell A4, then:
Cell B2 Formula: =VLOOKUP(B4,'Worksheet B'!A:B,2,0)
Cell B3 Formula: =VLOOKUP(B4,'Worksheet B'!A:C,3,0)
Cell B4 Formula: =VLOOKUP(B4,'Worksheet B'!A:D,4,0)