Getting Address of Current Value Throws 424 Error

soccerkingpilot

Board Regular
Joined
May 21, 2012
Messages
105
Hi Guys,
I'm having a really weird problem right now. I just used a simple for each operation with an if statement wrapped inside and I want to get the corresponding row number for the value that met my condition.

Code:
Set MnS = Workbooks("Metrics and Status.xls")
FAlog = Sheets("Critical").Cells(2, 2).Value
Set FAlogS = Workbooks(FAlog).Sheets("Cases")
lastrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
cllRng = FAlogS.Range("C4", "C" & lastrow)
For Each cll In cllRng
If cll > MnS.Sheets("Critical").Cells(2, 3) Then
    firstrow = cll.Row 'This is the line throwing the "Object Required" Error
    Exit For
End If

This one's got me scratching my head, and I have a feeling it's something very simple. Any ideas?

Thanks,
Austin
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I think this

Code:
cllRng = FAlogS.Range("C4", "C" & lastrow)
should be
cllRng = FAlogS.Range("C4:C" & LastRow)
 
Upvote 0
Austin

How have you declared LastRow?
 
Upvote 0
Object variables require Set:

Code:
[COLOR=#ff0000]Set [/COLOR]cllRng = FAlogS.Range("C4", "C" & lastrow)
 
Upvote 0
texasalynn, I think Range works both ways...you can write it as Range("A1:B1") or Range(fromhere,tohere)

shg's note fixed the problem. Thanks, didn't recognize Range as an object variable.

-Austin
 
Upvote 0
You would if you declared it :)
 
Upvote 0

Forum statistics

Threads
1,215,106
Messages
6,123,122
Members
449,096
Latest member
provoking

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