ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   conditional formating (https://www.excelbanter.com/excel-programming/436209-conditional-formating.html)

Harryd

conditional formating
 
I have used the code below, how do I run it for a table of existing data

Private Sub Worksheet_Change(ByVal Target As Range)

Dim icolor As Integer



If Not Intersect(Target, Range("A1:AA200")) Is Nothing Then

Select Case Target

Case 15000 To 20000

icolor = 4

Case 14000 To 14999

icolor = 43

Case 13000 To 13999

icolor = 10

Case 12000 To 12999

icolor = 6

Case 11000 To 11999

icolor = 44

Case 10000 To 10999

icolor = 45

Case 9000 To 9999

icolor = 46

Case 8000 To 8999

icolor = 3

Case Else

icolor = 2

End Select

Target.Interior.ColorIndex = icolor

End If

End Sub

--
Harry D

Don Guillett

conditional formating
 
for each c in range....
select case c

next c

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Harryd" wrote in message
...
I have used the code below, how do I run it for a table of existing data

Private Sub Worksheet_Change(ByVal Target As Range)

Dim icolor As Integer



If Not Intersect(Target, Range("A1:AA200")) Is Nothing Then

Select Case Target

Case 15000 To 20000

icolor = 4

Case 14000 To 14999

icolor = 43

Case 13000 To 13999

icolor = 10

Case 12000 To 12999

icolor = 6

Case 11000 To 11999

icolor = 44

Case 10000 To 10999

icolor = 45

Case 9000 To 9999

icolor = 46

Case 8000 To 8999

icolor = 3

Case Else

icolor = 2

End Select

Target.Interior.ColorIndex = icolor

End If

End Sub

--
Harry D




All times are GMT +1. The time now is 03:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com