A: 

AFAIR u can't work with worksheet_change because it doesn't fire if you only change the background color. The simplest solution is to add a button with the caption "highlight matrix" that walks through your sensordata and highlights the found rows in the matrix.

Private Sub highlightMatrix()
Dim SensorData As Range
Dim Matrix As Range
Dim yellowRows As Collection
Dim isYellow As Boolean
Dim iColumn As Integer

Set SensorData = Worksheets.Item(1).Cells(3, 1).CurrentRegion
Set Matrix = Worksheets.Item(1).Cells(3, 10).CurrentRegion
Set yellowRows = New Collection

For Each Row In SensorData.Rows     ' walk the used rows of sensordata '
    isYellow = False
    iColumn = 3

    While iColumn >= 3 And iColumn <= 8 And isYellow = False    ' identify rows with yellow marked sensordata '
        If Row.Cells(1, iColumn).Interior.ColorIndex = 6 Then
            isYellow = True
            yellowRows.Add (Row.Row)
        End If
        iColumn = iColumn + 1
    Wend
Next Row

Matrix.Interior.ColorIndex = xlNone  ' set matrix background to default '
For Each Item In yellowRows
    For Each Row In Matrix.Rows
        If Row.Cells(1, 1) = Worksheets.Item(1).Cells(Item, 1) And Row.Cells(1, 2) = Worksheets.Item(1).Cells(Item, 2) Then ' color found rows red '
            Row.Cells(1, 1).Interior.ColorIndex = 3
            Row.Cells(1, 2).Interior.ColorIndex = 3
            Row.Cells(1, 3).Interior.ColorIndex = 3
        End If
    Next Row
Next Item

Set yellowRows = Nothing

End Sub

Its not the most efficient way to solve this problem but it should be fine with small worksheets.

Adding more Sensors: The array/collection yellowRows stores the rownumbers of every key1/key2 combination that has at least one yellow sensor value. If you want to add other sensors, u could add the columns after the current 6 sensor rows (C - H) and set the matrix row to the new column position e. g. 13 instead of 10 and set iColumn <= 11 instead of 8 if u add 1 new sensor with 3 columns.

Adding more Matrices: To add more matrices u simply need to add a matrix in the given layout anywhere and define a new range for the matrix e.g.

Set Matrix2 = Worksheets.Item(1).Cells(100, 1).CurrentRegion 'Matrix 2 starts in the 100. row on the 1. spreadsheet in the 1. column'

then just copy+paste the for loop of your original matrix(and change Matrix.Rows in Matrix2.Rows) in the yellowRows loops (now u have 2 Loops in your yellowRows loop)

Regarding your Sample file:

  • There was a "End Sub" at the start of the Sub that needed to be deleted
  • The Matrix range was set wrong
  • the sensordata should start at column
  • Because you have an id column the line

       If Row.Cells(1, 1) = Worksheets.Item(1).Cells(Item, 1) And Row.Cells(1, 2) = Worksheets.Item(1).Cells(Item, 2) Then ' color found rows red '
    

    changes to

       If Row.Cells(1, 1) = Worksheets.Item(1).Cells(Item, 2) And Row.Cells(1, 2) = Worksheets.Item(1).Cells(Item, 3) Then ' color found rows red '
    
  • the column loop should start at 5 and end at 16

Here is the modified Sample File: http://www.mediafire.com/?vkbyv1n4m0t

marg
Thank you for taking a shot at this but the code did not work. It did no highlighting at all. Tried to modify it by declaring a range for Matrix and SensorData and removing Private from the sub statement but to no avail. The other question I have is in the nature of the approach; this is using cell counting so how would that work if I have "Matrix 2", "Matrix 3", etc... as well?
e9
And also, "Sensor 3", "Sensor 4", "Sensor 5". I'm thinking if I can somehow declare ranges instead, it might be more amenable.
e9
It worked on my spreadsheet that I created for test purposes(based on the image). Did u fire the sub by creating a button and sending it to highlightMatrix ?Could you upload a spreadsheet with the deisred layout and some exampledata and your vba script? I will edit the answers to the other questions in my answer.
marg
I have added the sample file with my modified code above. File factory where the file is located does not work well.
e9
I have found a few bugs in your file and one in my original code (changed SourceData.(Item, 1) to Worksheets.Item(1).Cells(Item, 1))My uploaded samplefile works for me
marg
Thank you so much marg! I cannot express my sincere appreciation. Takes me an average of 4hours to do that manually.
e9
you are welcome :)
marg
Marg, after using the modified code for several weeks now, I've discovered an error in the code that you helped me with. The problem is that it doesn't care about the relative position of the sensor data. "12" is supposed to correspond to "AB", "23" corresponds to "BC", and "13" corresponds to "AC". In the sample file that you posted, for (key1, key2) = (0,4) with peud13 (more clearly, peudAC) highlighted yellow, Matrix 1 for no. 2, 6, 8, 10, and 11 is highlighted red when it shouldn't because (0,4) is in AB and not AC. Can you help me correct this error? Thank you.
e9
Also, if you look at the sample spreadsheet above, even though (key1,key2) = (0,5) in sensor 2 (position AC), the matrix for rows (057, 058, and 059) doesn't show it highlighted red. The modified code above, ignores this important point and highlights all three rows when it shouldn't because of (0,5) in the matrix is for position (AB) and not (AC).
e9
Sorry I have a hard time understanding the problem. My understanding was, that if any sensor has a yellow highlighted value, all matrix lines that have key1 in the first cell (excluding line no.) and key2 in the second cell should be marked red.
marg
My apologies for that, I try to explain as best I can. All matrix lines that have key1 in the first cell (excluding line no.) and key2 in the second cell should be marked red only if the highlighted yellow sensor value position corresponds to the position in the matrix. So if the named column shows position '12' (i.e.AB) highlighted yellow, yet the match with the matrix is position AC (i.e.13), that row should not be highlighted red in the matrix.
e9
Ok I'm still confused. I gather that the sensor coumns are *12=AB;*23=BC;*13=AC. It might help me to know whether the SensorNumber; the value in the 3. matrix column or the matrix column headings should have any effect on the highlighting.
marg
You're correct above. The values in row 2 under each Sensor position whether it is AB,BC,or AC determines whether or not whether a row in the Matrix should be highlighted red.
e9
Wel what about SensorNumber, thev alue in 3. matrix column or the matrix column headings?I think it would be best if you would edit your question and add a more extensive explanation on the highlighting process and all the criteria that affect highlighting.
marg
Marg, I've imposed enough on you and appreciate all of the assistance you've provided me thus far. I'll use what I have and figure out another way to overcome my obstacles. Thank you again.
e9
ok. you are welcome.
marg