VBA noob here...
What would be the easiest and cleanest way to perform the following please?
1) User inputs desired criteria in Column B, and clicks the button to perform find&highlight function (can be very long criteria listed)
2) Macro collects all criteria, finds all cells in the list (Colmn A) that begins with any criteria from column B, and highlights the cells in Column A in red.
My ideas would be to get B1 into 'criteria' as string, determines the number of chars in the 'criteria', and use LEFT function to locate any cells matches (begins with) in column A and highlights in red.
And then get B2, B3, B4...until end of the Column B.
However, this would require using a FOR loop, which could be slow if the list is 10000+ rows.
Also, LEFT function would require number of chars, which I'll have to determine for every criteria.
Is there any faster and easier way?
An example of sample data and result are below.
Raw data:
[TABLE="class: grid, width: 500, align: left"]
List (Col A)
[/td]Criteria (Col B, User input examples)
[/td][TABLE="width: 170"]
[TD="width: 170"]absinths
[/TABLE]
[/TD]
absi
[/td][TABLE="width: 170"]
[TD="width: 170"]absent
[/TABLE]
[/TD]
ele
[/td][TABLE="width: 170"]
[TD="width: 170"]asenath
[/TABLE]
[/TD]
Com
[/td][TABLE="width: 170"]
[TD="width: 170"]Conformate
[/TABLE]
[/TD]
Confla
[/td][TABLE="width: 170"]
[TD="width: 170"]aseneth
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]conflict of interest
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]absinthes
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]confluent
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]abesant
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]absinthe's
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]Compete
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]absynth
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]abs
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]confiscable
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]conflate
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]eat
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]Electricity
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]confiscate
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]conflation
[/TABLE]
[/TD]
[TABLE="width: 170"]
[TD="width: 170"]conflagration
[/TABLE]
[/TD]
[/TABLE]
Result:
[TABLE="class: grid, width: 500, align: left"]
List (Col A)
[/td]absinths
[/td]absent
[/td]asenath
[/td]Conformate
[/td]aseneth
[/td]conflict of interest
[/td]absinthes
[/td]confluent
[/td]abesant
[/td]absinthe's
[/td]Compete
[/td]absynth
[/td]abs
[/td]confiscable
[/td]conflict
[/td]eat
[/td]Electricity
[/td]confiscate
[/td]conflation
[/td]conflagration
[/td]
[/TABLE]