Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,560
Default Selecting cells of a specific color only.

Is there a way to find and select cells only of a certain color in order to
speed the formating of these cells. Any help would be appreciated.

Thanks David
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Selecting cells of a specific color only.

David,

You can use the code below to do this. The function RangeOfColor returns a
range containing the cells of the OfRange parameter which have a ColorIndex
equal to the ColorIndex parameter. If the OfText parameter is omitted or
False, the background fill color is tested. If OfText is True, the font
color of each cell is tested. You can then call this function with code
similar to the SelectRangeOfColor procedure below.

Function RangeOfColor(OfRange As Range, _
ColorIndex As Long, Optional OfText As Boolean) As Range
Dim ResRange As Range
Dim R As Range

For Each R In OfRange.Cells
If OfText = True Then
If R.Font.ColorIndex = ColorIndex Then
If ResRange Is Nothing Then
Set ResRange = R
Else
Set ResRange = Application.Union(ResRange, R)
End If
End If
Else
If R.Interior.ColorIndex = ColorIndex Then
If ResRange Is Nothing Then
Set ResRange = R
Else
Set ResRange = Application.Union(ResRange, R)
End If
End If
End If
Next R
Set RangeOfColor = ResRange

End Function

Sub SelectRangeOfColor()

Dim RR As Range
Dim ColorIndex As Long
Dim OfText As Boolean

ColorIndex = 3 ' RED. See help on ColorIndex for other values
OfText = False ' FALSE - test fill color, TRUE - test font color

If TypeOf Selection Is Excel.Range Then
If Selection.Cells.Count = 1 Then
MsgBox "Select the range to test.", vbOKOnly
Else
Set RR = RangeOfColor(Selection, ColorIndex, OfText)
If Not RR Is Nothing Then
RR.Select
End If
End If
Else
MsgBox "Select a range of cells and try again", vbOKOnly
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"David" wrote in message
...
Is there a way to find and select cells only of a certain color in order
to
speed the formating of these cells. Any help would be appreciated.

Thanks David


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Selecting cells of a specific color only.

Here is an example for Yellow#6:

Sub FindYellow()
Set r = Nothing
For Each rr In ActiveSheet.UsedRange
If rr.Interior.ColorIndex = 6 Then
If r Is Nothing Then
Set r = rr
Else
Set r = Union(rr, r)
End If
End If
Next
If r Is Nothing Then
Else
r.Select
End If
End Sub
--
Gary''s Student - gsnu200769


"David" wrote:

Is there a way to find and select cells only of a certain color in order to
speed the formating of these cells. Any help would be appreciated.

Thanks David

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Selecting cells of a specific color only.

In Excel 2003, you can use the find Tab of Find And Replace to locate
coloured cells.

Open a find and replace form

Leave the Find What: field blank

Click the options button

Click the dropdown arrow on the Format Button

Select the Choose Format From Cell option

Now click in a cell with the format that you want to amend

Click the Find All Button and cells with that formatting are shown in the
lower window.

Click each one to go to that cell and make format changes as required in
each cell.

Hope this helps!

--
Saruman

---------------------------------------------------------------------------
All Outgoing Mail Scanned By Symantec Antivirus 10
---------------------------------------------------------------------------
"David" wrote in message
...
Is there a way to find and select cells only of a certain color in order

to
speed the formating of these cells. Any help would be appreciated.

Thanks David



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,560
Default Selecting cells of a specific color only.

Chip,

Appreciate your fast response however I was hoping there was a way to do
this procedure by using the existing Excel menus or if you explain to me how
to use this code. I am a novice when it comes to programing.

"Chip Pearson" wrote:

David,

You can use the code below to do this. The function RangeOfColor returns a
range containing the cells of the OfRange parameter which have a ColorIndex
equal to the ColorIndex parameter. If the OfText parameter is omitted or
False, the background fill color is tested. If OfText is True, the font
color of each cell is tested. You can then call this function with code
similar to the SelectRangeOfColor procedure below.

Function RangeOfColor(OfRange As Range, _
ColorIndex As Long, Optional OfText As Boolean) As Range
Dim ResRange As Range
Dim R As Range

For Each R In OfRange.Cells
If OfText = True Then
If R.Font.ColorIndex = ColorIndex Then
If ResRange Is Nothing Then
Set ResRange = R
Else
Set ResRange = Application.Union(ResRange, R)
End If
End If
Else
If R.Interior.ColorIndex = ColorIndex Then
If ResRange Is Nothing Then
Set ResRange = R
Else
Set ResRange = Application.Union(ResRange, R)
End If
End If
End If
Next R
Set RangeOfColor = ResRange

End Function

Sub SelectRangeOfColor()

Dim RR As Range
Dim ColorIndex As Long
Dim OfText As Boolean

ColorIndex = 3 ' RED. See help on ColorIndex for other values
OfText = False ' FALSE - test fill color, TRUE - test font color

If TypeOf Selection Is Excel.Range Then
If Selection.Cells.Count = 1 Then
MsgBox "Select the range to test.", vbOKOnly
Else
Set RR = RangeOfColor(Selection, ColorIndex, OfText)
If Not RR Is Nothing Then
RR.Select
End If
End If
Else
MsgBox "Select a range of cells and try again", vbOKOnly
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"David" wrote in message
...
Is there a way to find and select cells only of a certain color in order
to
speed the formating of these cells. Any help would be appreciated.

Thanks David




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,560
Default Selecting cells of a specific color only.



Appreciate your fast response however I was hoping there was a way to do
this procedure by using the existing Excel menus or if you explain to me how
to use this code. I am a novice when it comes to programing.


"Gary''s Student" wrote:

Here is an example for Yellow#6:

Sub FindYellow()
Set r = Nothing
For Each rr In ActiveSheet.UsedRange
If rr.Interior.ColorIndex = 6 Then
If r Is Nothing Then
Set r = rr
Else
Set r = Union(rr, r)
End If
End If
Next
If r Is Nothing Then
Else
r.Select
End If
End Sub
--
Gary''s Student - gsnu200769


"David" wrote:

Is there a way to find and select cells only of a certain color in order to
speed the formating of these cells. Any help would be appreciated.

Thanks David

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,560
Default Selecting cells of a specific color only.

Using this process, will I be able to replace all selected cell formats on a
bulk basis.
Basicall I am trying to select all yellow highlighted cells(input fields)
and unprotect them. If there is an easier way, please let me know.

Thanks for your help.

"Saruman" wrote:

In Excel 2003, you can use the find Tab of Find And Replace to locate
coloured cells.

Open a find and replace form

Leave the Find What: field blank

Click the options button

Click the dropdown arrow on the Format Button

Select the Choose Format From Cell option

Now click in a cell with the format that you want to amend

Click the Find All Button and cells with that formatting are shown in the
lower window.

Click each one to go to that cell and make format changes as required in
each cell.

Hope this helps!

--
Saruman

---------------------------------------------------------------------------
All Outgoing Mail Scanned By Symantec Antivirus 10
---------------------------------------------------------------------------
"David" wrote in message
...
Is there a way to find and select cells only of a certain color in order

to
speed the formating of these cells. Any help would be appreciated.

Thanks David




  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Selecting cells of a specific color only.

Yes

Slight change to procedure

Use the Replace Tab

Same other buttons, but in the Replace dropdown Format arrow, select a cell
with the colour format that you require.

Find All then Replace All.

Try on a copy of the original first until you perfect it.

May need to format a blank cell with a colour you want first so you can
select it during the replace operation of the formatting

--
Saruman

---------------------------------------------------------------------------
All Outgoing Mail Scanned By Symantec Antivirus 10
---------------------------------------------------------------------------
"David" wrote in message
...
Using this process, will I be able to replace all selected cell formats on

a
bulk basis.
Basicall I am trying to select all yellow highlighted cells(input fields)
and unprotect them. If there is an easier way, please let me know.

Thanks for your help.

"Saruman" wrote:

In Excel 2003, you can use the find Tab of Find And Replace to locate
coloured cells.

Open a find and replace form

Leave the Find What: field blank

Click the options button

Click the dropdown arrow on the Format Button

Select the Choose Format From Cell option

Now click in a cell with the format that you want to amend

Click the Find All Button and cells with that formatting are shown in

the
lower window.

Click each one to go to that cell and make format changes as required in
each cell.

Hope this helps!

--
Saruman


--------------------------------------------------------------------------

-
All Outgoing Mail Scanned By Symantec Antivirus 10


--------------------------------------------------------------------------

-
"David" wrote in message
...
Is there a way to find and select cells only of a certain color in

order
to
speed the formating of these cells. Any help would be appreciated.

Thanks David






  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,560
Default Selecting cells of a specific color only.

Thanks,

Will try. Appreciate your help

"Saruman" wrote:

Yes

Slight change to procedure

Use the Replace Tab

Same other buttons, but in the Replace dropdown Format arrow, select a cell
with the colour format that you require.

Find All then Replace All.

Try on a copy of the original first until you perfect it.

May need to format a blank cell with a colour you want first so you can
select it during the replace operation of the formatting

--
Saruman

---------------------------------------------------------------------------
All Outgoing Mail Scanned By Symantec Antivirus 10
---------------------------------------------------------------------------
"David" wrote in message
...
Using this process, will I be able to replace all selected cell formats on

a
bulk basis.
Basicall I am trying to select all yellow highlighted cells(input fields)
and unprotect them. If there is an easier way, please let me know.

Thanks for your help.

"Saruman" wrote:

In Excel 2003, you can use the find Tab of Find And Replace to locate
coloured cells.

Open a find and replace form

Leave the Find What: field blank

Click the options button

Click the dropdown arrow on the Format Button

Select the Choose Format From Cell option

Now click in a cell with the format that you want to amend

Click the Find All Button and cells with that formatting are shown in

the
lower window.

Click each one to go to that cell and make format changes as required in
each cell.

Hope this helps!

--
Saruman


--------------------------------------------------------------------------

-
All Outgoing Mail Scanned By Symantec Antivirus 10


--------------------------------------------------------------------------

-
"David" wrote in message
...
Is there a way to find and select cells only of a certain color in

order
to
speed the formating of these cells. Any help would be appreciated.

Thanks David






  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Selecting cells of a specific color only.

In addition to Saruman's suggestion.

After hitting the Find All button as instructed below, in the Found Dialog Box
you can hit SHIFT + End to select all found cells and apply formatting to all at
once if desired.


Gord Dibben MS Excel MVP


On Thu, 14 Feb 2008 00:01:06 -0000, "Saruman" wrote:

In Excel 2003, you can use the find Tab of Find And Replace to locate
coloured cells.

Open a find and replace form

Leave the Find What: field blank

Click the options button

Click the dropdown arrow on the Format Button

Select the Choose Format From Cell option

Now click in a cell with the format that you want to amend

Click the Find All Button and cells with that formatting are shown in the
lower window.

Click each one to go to that cell and make format changes as required in
each cell.

Hope this helps!

--
Saruman


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional to change cell color by Selecting Cells maperalia Excel Discussion (Misc queries) 4 June 24th 07 06:53 AM
how to count cells with specific format (background color)? Blackheartedowl Excel Discussion (Misc queries) 1 February 8th 06 08:21 AM
Sum formula of cells with specific color value MSOChick Excel Worksheet Functions 2 December 9th 05 10:19 AM
Selecting cells that contain text in a specific format nicad_adam Excel Discussion (Misc queries) 1 June 17th 05 05:19 AM
how to color code a row of cells based on a specific cell value Parker1333 New Users to Excel 1 February 2nd 05 08:01 AM


All times are GMT +1. The time now is 09:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"