TheRedCardinal
Active Member
- Joined
- Jul 11, 2019
- Messages
- 250
- Office Version
- 365
- 2021
- Platform
- Windows
The main objective I want to achieve is to run through a stack of data (8000 rows and 12 columns) and see if the value of a specific column for each row matches a number of options (ideally to be specified by the user) and if so, to delete that row.
Now I could do this relatively easily using a loop through the spreadsheet and then deleting rows that match conditions.
But this could take some time, so I wanted to use arrays.
My outline plan is this:
Now I could do this relatively easily using a loop through the spreadsheet and then deleting rows that match conditions.
But this could take some time, so I wanted to use arrays.
My outline plan is this:
- Load the whole data into an array, called Array 1
- ReDim a second array to the same size
- Find the column containing the data test I need
- Do a For/Next loop using UBound(Array1) and check if the entry at the position matches any of the excluded values
- If it doesn't, using a second loop, copy it over into the next blank line in Array 2
- Clear the contents of the worksheet
- Post Array2 back into the worksheet
- Ideally I'd like a list of excluded codes that the user can edit - what is the best way to do this - should I create a range and have each excluded code in a single cell in that range?
- Or could I have a single cell which contains separated codes, e.g. "EX, EP, ET"
- Based on option 1 or 2, how do I then write a formula in VBA that checks the value in the array against ALL possible outcomes, without having a heavily nested IF formula
- Is my outline method above the best approach to this?