Translating numbers into number with color pattern

  • Thread starter Thread starter Harry88
  • Start date Start date
H

Harry88

I am trying to create attention catching number pattern but I don't wan
to manually enter each color pattern formating. Is there a way where
enter a number and its associated color pattern will appear on th
number in another place ?

For example: series number in one column 1,2,3 4 ,5,6,7,8,9,10

I enter 1, 5, 7 on separate column

column 1,2,3 4 ,5,6,7,8,9,10

1, 5 & 7 's background color(pattern color) for the column will chang
to yellow.

How to associate a particular group of numbers with certain patter
color ?

Thanks..
 
Hi Harry, in the code below, I gave the main numerical list (1,2,3,4,5,...)
the range name, "DataList". I gave the highlight items list (1,5,7 in your
example), the range name "HighlightList".

Sub HighlightListValues()
'Highlight values in a data list that are common to a highlight values list
Dim i As Integer, j As Integer
Dim DataListRows As Integer, HighlightListRows As Integer

'Determine the number of items in the data list and the highlights list
DataListRows = Application.WorksheetFunction.CountA(Range("DataList"))
HighlightListRows =
Application.WorksheetFunction.CountA(Range("HighlightList"))

'Clear any currently highlighted items in the data list
Range("DataList").Interior.ColorIndex = xlNone

'Highlight items in the data list that are also in the highlights list
For i = 1 To HighlightListRows
For j = 1 To DataListRows
If Range("DataList").Cells(j, 1).Value =
Range("HighlightList").Cells(i, 1).Value Then
Range("DataList").Cells(j, 1).Interior.ColorIndex = 36
End If
Next j
Next i

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top