Filtering data using a dictionary

Demirion

Board Regular
Joined
Sep 21, 2022
Messages
66
Platform
  1. Windows
Hi, I would like to create a macro that will filter the data, but the problem is, I don't know exactly what the data will be in the file. For this purpose, I used a dictionary that goes through a given column and saves the keys that I want to filter later. Unfortunately, I don't know how to get data from this dictionary. Below, the loop that goes through the given column. I added Debug.Print to check if the dictionary is working properly.
VBA Code:
For Each key In dictCity.Keys
Set oCity = dictCity(key)
With oCity
Debug.Print key
ws1.Range("A1").Autofilter Field:=1, Criteria1:=key, Operator:=xlFilterValues
End With
Next key
 
Thanks for the help. Everything works rigidly. Now I go back to the dictionaries. Earlier, I only mentioned one dictionary because I didn't want to complicate the macro. There must be three dictionaries. One is for cities (column A), the other is for users (column B), and the third is for errors (column C). After creating a dictionary with cities, I filter by items from the dictionary. After filtering, I create a dictionary with users who are in a given city and also using items from the dictionary filters data in the table with users. Finally, from what is left, I create a third dictionary with errors which I use to filter the data on the sheet with errors. And this is how I would like to generate an email for users. As I mentioned rigidly, I managed to do it for a single city and user. If I had to do it rigidly for everything, it would take a long time because there are several thousand items. In addition, I do not know what exactly will be in the file, so it would work hard only for a specific file. I know this is a long and complicated macro but maybe you used to do a similar one and could you guide me on how to do it?
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,215,223
Messages
6,123,715
Members
449,118
Latest member
MichealRed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top