Thank you for your prompt reply.
Here is a copy of the code.
It is in the early stages of development!
Essentialy I want to validate data in a worksheet against reference data (defined upper and lower limits) in another spreadsheet.
For example a record with a "mat_ox" value of "blabla" would have defined upper and lower limits for each measure eg copper (Cu) Uranium (U) and Specific Gravity (SG). The macro tests each value aganst the data in Ref_Table spreadsheet and if the value is outside the upper and lower limits the cell is flagged (infilled red).
Sheets("Chimi").Select
For Each Record In Product_List
Dim mat_ox
Sheets("Chimi").Select
mat_ox = Record.Offset(0, 1) + Record.Offset(0, 2)
Sheets("Ref_Tables").Select
CU_LL = Evaluate("INDEX($E$4:$E$23,MATCH(" & mat_ox & ",$C$4:$C$23&$D$4:$D$23,0))")
CU_UL = Evaluate("INDEX($F$4:$F$23,MATCH(D1,$C$4:$C$23&$D$4:$D$23,0))")
U_LL = Evaluate("INDEX($G$4:$G$23,MATCH(D1,$C$4:$C$23&$D$4:$D$23,0))")
U_UL = Evaluate("INDEX($H$4:$H$23,MATCH(D1,$C$4:$C$23&$D$4:$D$23,0))")
SG_LL = Evaluate("INDEX($I$4:$I$23,MATCH(D1,$C$4:$C$23&$D$4:$D$23,0))")
SG_UL = Evaluate("INDEX($J$4:$J$23,MATCH(D1,$C$4:$C$23&$D$4:$D$23,0))")
If Record.Offset(0, 7) >= CU_LL And Record.Offset(0, 7) <= CU_UL Then
MsgBox "Cu fails"
Else
Record.Offset(0, 7).Interior.Color = RGB(100, 0, 0)
End If
If Record.Offset(0, 7) >= U_LL And Record.Offset(0, 7) <= U_UL Then
Else
Record.Offset(0, 7).Interior.Color = RGB(100, 0, 0)
End If
If Record.Offset(0, 7) >= SG_LL And Record.Offset(0, 7) <= SG_UL Then
Else
Record.Offset(0, 7).Interior.Color = RGB(100, 0, 0)
End If
Next
'--------------------------------------------------------------
End Sub
Bookmarks