Happy Friday, I am attempting to find the last green (color Id=5287936) filled cell for each row in a data set. Once found I need to report the appropriate column label - (text present in row 4), for each identified green filled cell. I know I would need a for loop in order to loop through the whole dataset (multiple rows), but thought I'd start with just one row. My code is as follows:
_____________________________________________________________________________________________________
Sub findgreen()
ActiveWorkbook.RefreshAll 'Refreshes/Pulls data
Dim s As Worksheet
Set s = ActiveSheet ' look on the active sheet
'Set s = ThisWorkbook.Worksheets("Sheet1") ' look on a specific sheet
Dim color As Long
color = 5287936 ' enter the result of the statement above here
Dim row As Integer
row = 1
Dim col As Integer
For col = s.Columns.Count To 1 Step -1
If s.Cells(row, col).Interior.color = color Then Exit For
Next
s.Activate
s.Cells(row, col).Select ' *** Debug stopped here
End Sub
___________________________________________________________________________________________________________________
However, I am receiving an error: application-defined or object-defined error at the " s.Cells(row,col).Select" line
Again, I am new to this. Any input in terms of code adjustment or resources would be greatly appreciated.
Thank you in advance,
_____________________________________________________________________________________________________
Sub findgreen()
ActiveWorkbook.RefreshAll 'Refreshes/Pulls data
Dim s As Worksheet
Set s = ActiveSheet ' look on the active sheet
'Set s = ThisWorkbook.Worksheets("Sheet1") ' look on a specific sheet
Dim color As Long
color = 5287936 ' enter the result of the statement above here
Dim row As Integer
row = 1
Dim col As Integer
For col = s.Columns.Count To 1 Step -1
If s.Cells(row, col).Interior.color = color Then Exit For
Next
s.Activate
s.Cells(row, col).Select ' *** Debug stopped here
End Sub
___________________________________________________________________________________________________________________
However, I am receiving an error: application-defined or object-defined error at the " s.Cells(row,col).Select" line
Again, I am new to this. Any input in terms of code adjustment or resources would be greatly appreciated.
Thank you in advance,