Go down a cell until it finds a grey colored cell

Doblon

Board Regular
Joined
Jul 27, 2009
Messages
73
Hi I need help with programing a macros to go down a cell until it finds a grey colored cell. Is it possible?

So far i have the following:

Sub AlimentaciónPanelLegacy()
Dim LC As Long
Dim RC As Long
Sheets("Action Items").Select
Range("C1").Select

Do Until ActiveCell.Value = GREY COLORED CELL
ActiveCell.Offset(1, 0).Select
Loop

Range("A1").Select
End Sub

Many thanks!:)
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Not sure what shade of grey you are using... try:

Code:
Sub GreyRow()
Dim LR As Long, i As Long
LR = Sheets("Action Items").Range("C" & Rows.Count).End(xlUp).Row
For i = 1 To LR
   If Sheets("Action Items").Range("C" & i).Interior.ColorIndex = 15 Then
      Sheets("Action Items").Range("C" & i).Select
   End If
Next i
End Sub

If that doesn't work, change the ColorIndex = 15 to 48 or 16.
 
Upvote 0
Try like this - you might need to change the 56 to match the shade of grey

Rich (BB code):
Sub AlimentaciónPanelLegacy()
Dim r As Range
Sheets("Action Items").Select
Set r = Range("C1")

Do Until r.Interior.ColorIndex = 56
    Set r = r.Offset(1)
Loop

r.Select
End Sub
 
Upvote 0
Like this (depending on what colour grey you used!)
Code:
Sub d()
Dim MyCell As Range
'this next line only works if there is a value in the cell too, if this
'is not the case then hard code the range like this Range("C1:C100")
For Each MyCell In Range("C1:C" & Range("C" & Rows.Count).End(xlUp).Row)
If MyCell.Interior.ColorIndex = 48 Then
MsgBox MyCell.Address & " is Grey"
End If
Next MyCell
End Sub
 
Upvote 0
If i was you i'd go with Vog's code, short, to the point and doesnt rely on the cell containing a value, although i wouldnt Select the sheet i'd use a With! :)
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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