Compile error: object required

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"


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
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi & welcome to MrExcel.
Remove the word Set from this line
Code:
 Set goodRowCount = 0
 
Upvote 0
Thank you for the quick response, I have to remove "set" from at another but tat seems t work. If you don't mind can you explain why that work ? I thought you always need "set except when the variable is string
 
Upvote 0
You're welcome & thanks for the feedback.
Only Objects need Set.
 
Upvote 0

Forum statistics

Threads
1,216,103
Messages
6,128,854
Members
449,472
Latest member
ebc9

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top