I am looking to delete rows in a table based on multiple filter criteria - excel

I have been using Excel VBA for some time but am now looking to do something with the filters or similar.
I have a large table of data (in excess of 11000 rows) and I need to select up to 5 different criteria in a filter and basically delete each row which does not apply to this filter. (So effectively delete the invisible rows)
The filter needs to be set from an array of information in another listobject
The data in question is a list of staff members in departments set as a listobject - I need to only pull out whichever departments are selected from my criteria on another worksheet. The depts are Management, Warehouse, Stores, Admin, Transport. I need to delete all records which are NOT Warehouse, Stores or Admin
*I haven't really tried anything as I have been scouring the internet - I've had some thoughts aroung looping through the filter options
*Sorry - I have tried different things such as the for each row in table loop but this timed at over 15 minutes! (Apologies to the person who commented as I should've advised on this)
Sorry I have no code - barring "for each row in table" loop which I need to avoid using as this is a very slow process with this many records
Had no actual results - been using VBA for years but this is the first time I've been asked for this type of thing and I am at a loss.
Please be kind as I am new to the forum and obviously just looking for some help

Having trawled massive amounts of items I am sure there is an easier way but I have resolved this by converting the data back to a range, performaing the loop from the last to first row and deleting the row if the value is not found!
I'm happy with this as it now takes less than 15 seconds to complete - not sure why the list object was slowing it but I'm happy enough with it as is

Related

Comparing two tables of different size, with multiple columns in VBA

Looking to use VBA to compare two tables, with three columns each against each other. Beginner here and very lost.
They may have a different amount of entries each, and there may be some in table A that aren't in table B, and vice versa
Some of the individual Columns may match but trying to work out how to make sure all three columns are compared as one against all three columns in the other table
For example
xyz123 55.50 12/07/21 if compared with XYZ123 54.55 12/07/21 will show up as not a match, because the middle column is a different number.
Have attached a picture below. For the most part, and unlike the photo, each table will be in a completely random order, and its unlikely that there will be the same entry in table 1, row 1, as table 2 row 1
Ideally, I'm trying to create two new table to the right of the original tables, the first one being the entries table 1 has, that table 2 does not have. The second one being the entries table 2 has, that table 1 does not have.
Have attached an example below of the end result I'm looking for out of this. The four rows on the left are entries that the first table has but the second table doesn't, and the rows to the right are all entries that the second table has, but the first table does not.
I've tried to search on this but haven't found something that matches what I've got, and I'm struggling to adapt someone else's code to my specific problem
Any help on this would be greatly appreciated
Maybe not a direct answer to your problem but is this data also in a database somewhere or are you familiar with Ms Access? As you could open the tables in Access, and it is pretty easy to do this kind of thing with data bases.
If not, then yes, it is do able with VBA. Numerous ways of doing it.
The simplest is to scroll through one table a line at a time and compare it with every row in the other table and match or not. This will work with small tables and be easy and quick but for large data tables it would be wasteful and may take a long time to complete.

Criteria of SUMIF Function referring to data previously in table

Is there a way to add values in Excel based off of values previously in table?
For example, in the table I currently have, is there a way to exclude adding the 1 from the "Attended" column in the "Sonics and Cold Cash" row because I already had a row with "Sonics" and "1" in attended? I don't want to add a 1 to the SUMIF function if I have already attended that team once before.
I hope this is clear enough for some help. Thank you!
edit: So far, I have a table that tracks how many times a team has been "attended". This works, however I am trying to use linear optimization for scheduling, and using the results table has some linearity problems. I'm trying to find a way to only use the table instead of a second, results table.

Pivot table, multiple spreadsheets

I have multiple spreadsheets that all have different data. I tried multiple consolidation ranges but it didn't let me select the data I wanted.
I have 2 columns in each spreadsheet (many) with the same table title that I want to use (they are not in the same place in each sheet, and are only one of many columns - this cannot be changed). I still want to combine them without manually copying them as this takes too much time.
I have "Quality" and "Date". For "Quality" I have "Good" and "Bad". I want to be able to create a pivot where I can select "Quality: Good/Bad" as the report filter, then show the dates in the first column below and a count on the right (so I can see if there has been any new "Bad" ones for example in the later dates, like "Ah, a new date has appeared, and there is two new bad ones).
Can this even be done? I have twisted and turned and not come up with anything but errors.
Pivot tables will only take data form one source.
If you're desperate to use Powerpivot, then your options are either to:
A: Create a "master" table that pulls all the data into one place
B: use Powerpivot, as it can use data from more than one source.
Difficulty here is of course learning a completely new program and syntax (dax is similar but very different to Excel's formulaic language)
If you go down the powerpivot route, I found ExcelIsFun's tutorials on youtube incredibly useful.

Looking up values from different tables including newly found values

I have several documents which contain statistical data of performance of companies. There are about 60 different excel sheets representing different months and I want to collect data into one big table. Original tables looks something like this, but are bigger:
Each company takes two rows which represent their profit from the sales of the product and cost to manufacture the product.I need both of these numbers.
As I said, there are ~60 these tables and I want to extract information about Product2. I want to put everything into one table where columns would represent months and rows - profit and costs of each company. It could be easily done (I think) with INDEX function as all sheets are named similarly. The problem I faced is that at some periods of time other companies enter the market:
Some of them stay, some of them fail. I would like to collect information on all companies that exist today or ever existed, but newly found companies distort the list (in second picture we see, that company BA is in 4th row, not BB). As row of a company changes from time to time, using INDEX becomes problematic, because in some cases results of different companies get into one row. Adjusting them one by one seems very painful.
Maybe there is some quick and efficient method to solve such problem?
Any help or ideas would be appreciated.
One think you may want to try is linking the Excel spreadsheets as tables in Access. From there you can create a query that ties the tables together. As data changes in the spreadsheets, the query will reflect those changes.

What is the best way to filter a large list in Excel?

I have a table in Excel that I want to filter. It will have a maximum of 1 million rows and 80 columns. All the calculations etc are done programatically in arrays to cut dwn processing time. However, I want to also filter the results to display only certain results based on one column value, followed by a top 5% based on another filter value.
When I first did the sheet, it was limited to 65000 results so there were no problems with the size of the data set. I just invoked the worksheet filter functions from code and did it that way. Can I do it that way with a larger data set or is there a way to filter an array the way you d a dataset on a sheet?
Thanks
As already mentioned by everyone, excel 2007 will take you to a million rows, but its slower than the excel 2003 that I presume you're using at the moment so filtering using it wouldn't be advisable.
Along with mysql, ms access is also an option.
You really should put that data in an Access table and use Excel's Database Query to do the job. Since it can also filter retrieved data based on a cell value, it's a great combination.
Storing the data in a database brings you another interesting option (depending on what you want to do): to query your database using PowerPivot.
Although using a relational DB would be preferable in many ways, if you don't have any formulas then filtering your data (1 million rows by 80 columns) using Excel will be reasonably fast (< 1 or 2 seconds depending on what sort of filtering you want to do, which will probably be faster than an un-indexed DB table) assuming that you have enough RAM. If you do have any formulas then you will probably need to be in Manual calculation mode to avoid the filtering process triggering multiple recalculations.

Resources