andy7172289
Technical User
Hi all,
I need to select a particular colour from some RGB numbers, and it must be done by VBA as a formula would be limited to only 56 colours. Can someone tell me why I cannot save the macro below to use again in the future?
___________________________________________________________________________________________________________________
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, cell As Range
Dim i As Long
Set rng = Intersect(Target, Range("A:C"))
If Not rng Is Nothing Then
On Error Resume Next
For Each cell In Target.Columns(1).Cells
If Application.CountA(Range("A" & cell.Row & ":C" & cell.Row)) < 3 Or _
Application.Count(Range("A" & cell.Row & ":C" & cell.Row)) < 3 Then GoTo next_row
Cells(cell.Row, "D").Interior.Color = _
RGB(Cells(cell.Row, "A").Value, Cells(cell.Row, "B").Value, Cells(cell.Row, "C").Value)
next_row:
Next cell
End If
End Sub
___________________________________________________________________________________________________________________
I need to select a particular colour from some RGB numbers, and it must be done by VBA as a formula would be limited to only 56 colours. Can someone tell me why I cannot save the macro below to use again in the future?
___________________________________________________________________________________________________________________
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, cell As Range
Dim i As Long
Set rng = Intersect(Target, Range("A:C"))
If Not rng Is Nothing Then
On Error Resume Next
For Each cell In Target.Columns(1).Cells
If Application.CountA(Range("A" & cell.Row & ":C" & cell.Row)) < 3 Or _
Application.Count(Range("A" & cell.Row & ":C" & cell.Row)) < 3 Then GoTo next_row
Cells(cell.Row, "D").Interior.Color = _
RGB(Cells(cell.Row, "A").Value, Cells(cell.Row, "B").Value, Cells(cell.Row, "C").Value)
next_row:
Next cell
End If
End Sub
___________________________________________________________________________________________________________________