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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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