0% found this document useful (0 votes)
40 views

Excel VBA Color Cell

This document provides an Excel VBA macro that colors cells in a range or column based on matching values from two separate lists in different columns. The macro loops through a range from rows 3 to 66 in column 5 to select words, and then loops from rows 3 to 81 in column 1 to check for matches and color those cells yellow if a match is found. The macro was created by Sergio Perez Rodriguez for a Houston seminar on Excel VBA macros in June 2020.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Excel VBA Color Cell

This document provides an Excel VBA macro that colors cells in a range or column based on matching values from two separate lists in different columns. The macro loops through a range from rows 3 to 66 in column 5 to select words, and then loops from rows 3 to 81 in column 1 to check for matches and color those cells yellow if a match is found. The macro was created by Sergio Perez Rodriguez for a Houston seminar on Excel VBA macros in June 2020.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Houston Seminar in Excel VBA Macros

Excel VBA Macro to color cells in a range


column.

Sergio Perez Rodriguez


EG, PDG, MSc

June 2020
Sub ColCel()

Dim nr As String

'63 Selected words from a list in column 5

For i = 3 To 66

nr = Cells(i, 5).Value

'Matching the 63 words and 78 words in a list in column 1

For j = 3 To 81

Select Case nr

' Coloring cells in column 1 where they have words equal to those in column 1

Case Is = Cells(j, 1).Value

Cells(j, 1).Interior.ColorIndex = 37

Case Else

'do nothing'

End Select

Next j

Next i

End Sub
Bibliography

Jelen, B., Syrstad, T. 2016. Excel 2016 VBA and Macros. Pearson Education.

You might also like