Greetings,
we use semi-huge parts lists in our company and I'd like to highlight certain parts in yellow. While I do have working VBA code, it operates kinda slowly the bigger our files get (between 200 to 500 rows).
Here's an example:
Not all options defined in the code get used in every parts list, but that's ok.
I read a lot of articles and forums for optimizing this routine (many saying that For Each is the slowest), but failed to understand how to implement their solutions to my code. So I am lookin for an efficient and faster operating routine that also lets me add new options whenever needed.
Any help in regards to the problem above is greatly appreciated!
SY24
we use semi-huge parts lists in our company and I'd like to highlight certain parts in yellow. While I do have working VBA code, it operates kinda slowly the bigger our files get (between 200 to 500 rows).
Here's an example:
Assembly.xlsx | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | Superstructure Name | ||||||
2 | Level | Pos. | Asm. No. | Asm. Name | Amount | ||
3 | 1......... | 1 | Fan | 1,000 | |||
4 | .2........ | 1 | Blades | 3,000 | |||
5 | .2........ | 2 | Motor | 1,000 | |||
6 | .2........ | 3 | Housing | 1,000 | |||
7 | .2........ | 4 | Oscillator | 1,000 | |||
8 | .2........ | 5 | Screws | 15,000 | |||
9 | .2........ | 6 | Base | 1,000 | |||
10 | .2........ | 7 | Switch | 1,000 | |||
11 | .2........ | 8 | Power Chord | 1,000 | |||
12 | .2........ | 9 | Grille | 1,000 | |||
Sheet1 |
VBA Code:
Dim rCell As Range
For Each rCell In Range("D:D")
If rCell.Value Like "*Motor*" Then
rCell.Interior.ColorIndex = 6
ElseIf rCell.Value Like "*Oscillator*" Then
rCell.Interior.ColorIndex = 6
ElseIf rCell.Value Like "*Switch*" Then
rCell.Interior.ColorIndex = 6
ElseIf rCell.Value Like "*Button Panel*" Then
rCell.Interior.ColorIndex = 6
End If
Next
Assembly.xlsx | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | Superstructure Name | ||||||
2 | Level | Pos. | Asm. No. | Asm. Name | Amount | ||
3 | 1......... | 1 | Fan | 1,000 | |||
4 | .2........ | 1 | Blades | 3,000 | |||
5 | .2........ | 2 | Motor | 1,000 | |||
6 | .2........ | 3 | Housing | 1,000 | |||
7 | .2........ | 4 | Oscillator | 1,000 | |||
8 | .2........ | 5 | Screws | 15,000 | |||
9 | .2........ | 6 | Base | 1,000 | |||
10 | .2........ | 7 | Switch | 1,000 | |||
11 | .2........ | 8 | Power Chord | 1,000 | |||
12 | .2........ | 9 | Grille | 1,000 | |||
Sheet1 |
Not all options defined in the code get used in every parts list, but that's ok.
I read a lot of articles and forums for optimizing this routine (many saying that For Each is the slowest), but failed to understand how to implement their solutions to my code. So I am lookin for an efficient and faster operating routine that also lets me add new options whenever needed.
Any help in regards to the problem above is greatly appreciated!
SY24