Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Microsoft Excel _ Color One Cell Based On The Conditional Format Of Another

Posted by: halefamily104 Nov 8 2019, 11:58 AM

Hi UA!

I have a question. Currently, I am using two formulas that I would like to combine into one. The first VB highlights the rows and columns for easy following:

[/code]Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
'Clear all cell colours
Cells.Interior.ColorIndex = 0
With Target
'Row and column highlightingfor the active cell
.EntireRow.Interior.ColorIndex = 19
.EntireColumn.Interior.ColorIndex = 19
End With
Application.ScreenUpdating = True
End Sub[code]

The second VB will color the cell based on a conditionally formatted cell:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Range("T16").Interior.Color = Me.Range("AC16").DisplayFormat.Interior.Color
End Sub[code]

Is there a way to combine this VBA? When I tried to combine it before, I received an "ambiguous name detected" error.

Any ideas?

Thanks so much!

Posted by: Debaser Nov 8 2019, 04:02 PM

Just move this line:

Me.Range("T16").Interior.Color = Me.Range("AC16").DisplayFormat.Interior.Color

to the top of the other SelectionChange code.

Posted by: halefamily104 Nov 13 2019, 09:05 AM


That did it Debaser!

Thanks so much!!!! notworthy.gif

woohoo.gif uarulez2.gif