Cyber_Snowman
New Member
- Joined
- May 1, 2019
- Messages
- 5
Below are my attempt to highlight cell that are within certain value across multiple column. The goodCellCount variable are use to keep track of the amount of cell within parameter and goodRowCount are to keep track of row that have all cells(column F to I) within parameters.
However,when I try to run the macro, a error message pop up with " Compile error: object required"
However,when I try to run the macro, a error message pop up with " Compile error: object required"
Code:
Sub f_audit()
' Chi Kin Choy 5/1/19
'
' funace_audit Macro
'
'
Dim goodRow() As Integer
Dim dataStart As Range, dataEnd As Range, dataRange As Range, checkRange As Range
Dim processType As Range, firstGoodTime As Range, lastGoodTime As Range, tempCell As Range
Dim lowGoodTemp As String, highGoodTemp As String
Dim i As Integer, j As Integer, goodCellCount As Integer
Dim goodRowCount As Integer
'highlight good temp and keep track of row that are good in all four temp point
Set goodRowCount = 0
For i = dataStart.Row To dataEnd.Row
If goodCellCount = 4 Then
Set goodRowCount = goodRowCount + 1
ReDim goodRow(1 To goodRowCount)
goodRow(goodRowCount) = i - 1
End If
goodCellCount = 0
'start the check for good temp
tempCell = Range("F" & i)
If tempCell.Value >= lowGoodTemp And tempCell.Value <= highGoodTemp Then
tempCell.Interior.Color = RGB(198, 239, 206)
goodCellCount = goodCellCount + 1
End If
tempCell = Range("G" & i)
If tempCell.Value >= lowGoodTemp And tempCell.Value <= highGoodTemp Then
tempCell.Interior.Color = RGB(198, 239, 206)
goodCellCount = goodCellCount + 1
End If
tempCell = Range("H" & i)
If tempCell.Value >= lowGoodTemp And tempCell.Value <= highGoodTemp Then
tempCell.Interior.Color = RGB(198, 239, 206)
goodCellCount = goodCellCount + 1
End If
tempCell = Range("I" & i)
If tempCell.Value >= lowGoodTemp And tempCell.Value <= highGoodTemp Then
tempCell.Interior.Color = RGB(198, 239, 206)
goodCellCount = goodCellCount + 1
End If
Next I
end sub