find first cell in data that is yellow

flong

New Member
Joined
Feb 5, 2004
Messages
9
Hi,

I am looking for a vba that can find the first cell in the spreadsheet that is yellow and make that cell active. The search can look down each column and across each row of data until the first yellow cell is found. The search does not have to be specific as long as the first yellow cell (upper left side) is found.

thanks
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi!
Try this!
Code:
Sub Looking for the yellowCell()
for each c in activesheet.userdange
    if c.interior.colorindex=6 'yellow then
          c.activate
          exit sub
    end if 
next c
end sub
 

flong

New Member
Joined
Feb 5, 2004
Messages
9
The for each...... statement does not seem to work?


......................................................................

Sub Looking_for_the_yellow_Cell()
For Each c In ActiveSheet.UserRange
If c.Interior.ColorIndex = 6 Then 'yellow then
c.Activate
Exit Sub
End If
Next c
End Sub
 

flong

New Member
Joined
Feb 5, 2004
Messages
9
I figured it out and thanks for the great help.......


Sub Looking_for_the_yellow_Cell()
For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 6 Then
cell.Activate
Exit Sub
End If
Next cell
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,322
Messages
5,769,448
Members
425,546
Latest member
DisMissive

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
Top