Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Filtering by Cell Background Color

Hello,

I have a large populated spreadsheet. Certain random cells of this
spreadsheet have a background color of red. Is there anyway to go down each
row of the spreadsheet and filter out all the rows that have a cell with the
background color of red? The colored cells are located in different columns.
I need to filter/sort and get rid of the rows that have no color at all.
(that is - the colored cells are of importance)

I tried to seach for similar problems on here but found none. Any help
would be appreciated.

Thanks,
Terrel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Filtering by Cell Background Color

Sub DeleteRows()
Dim lastrow as long, lastColumn as Long
Dim i as Long, j as Long
Dim bColored as Boolean
LastRow = 500
LastColumn = 26
for i = lastrow to 2 step -1
bcolored = False
for j = 1 to lastcolumn
if cells(i,j).Interior.ColorIndex < xlNone then
bcolored = True
exit for
end if
Next
if not bColored then
rows(i).Delete
End if
Next
End if

Set values for LastRow and LastColumn
--
Regards,
Tom Ogilvy


"LoboNetwork" wrote in message
...
Hello,

I have a large populated spreadsheet. Certain random cells of this
spreadsheet have a background color of red. Is there anyway to go down

each
row of the spreadsheet and filter out all the rows that have a cell with

the
background color of red? The colored cells are located in different

columns.
I need to filter/sort and get rid of the rows that have no color at all.
(that is - the colored cells are of importance)

I tried to seach for similar problems on here but found none. Any help
would be appreciated.

Thanks,
Terrel



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Filtering by Cell Background Color

Thanks!
This is good.. But What if I dont want to delete the uncolored ones... hmm

"Tom Ogilvy" wrote:

Sub DeleteRows()
Dim lastrow as long, lastColumn as Long
Dim i as Long, j as Long
Dim bColored as Boolean
LastRow = 500
LastColumn = 26
for i = lastrow to 2 step -1
bcolored = False
for j = 1 to lastcolumn
if cells(i,j).Interior.ColorIndex < xlNone then
bcolored = True
exit for
end if
Next
if not bColored then
rows(i).Delete
End if
Next
End if

Set values for LastRow and LastColumn
--
Regards,
Tom Ogilvy


"LoboNetwork" wrote in message
...
Hello,

I have a large populated spreadsheet. Certain random cells of this
spreadsheet have a background color of red. Is there anyway to go down

each
row of the spreadsheet and filter out all the rows that have a cell with

the
background color of red? The colored cells are located in different

columns.
I need to filter/sort and get rid of the rows that have no color at all.
(that is - the colored cells are of importance)

I tried to seach for similar problems on here but found none. Any help
would be appreciated.

Thanks,
Terrel




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Filtering by Cell Background Color

Sub DeleteRows()
Dim lastrow as long, lastColumn as Long
Dim i as Long, j as Long
Dim bColored as Boolean
LastRow = 500
LastColumn = 26
Rows.Hidden = False
for i = lastrow to 2 step -1
bcolored = False
for j = 1 to lastcolumn
if cells(i,j).Interior.ColorIndex < xlNone then
bcolored = True
exit for
end if
Next
if not bColored then
rows(i).Hidden = True
End if
Next
End if

Hides the uncolored rows.

--
Regards,
Tom Ogilvy


"LoboNetwork" wrote in message
...
Thanks!
This is good.. But What if I dont want to delete the uncolored ones... hmm

"Tom Ogilvy" wrote:

Sub DeleteRows()
Dim lastrow as long, lastColumn as Long
Dim i as Long, j as Long
Dim bColored as Boolean
LastRow = 500
LastColumn = 26
for i = lastrow to 2 step -1
bcolored = False
for j = 1 to lastcolumn
if cells(i,j).Interior.ColorIndex < xlNone then
bcolored = True
exit for
end if
Next
if not bColored then
rows(i).Delete
End if
Next
End if

Set values for LastRow and LastColumn
--
Regards,
Tom Ogilvy


"LoboNetwork" wrote in message
...
Hello,

I have a large populated spreadsheet. Certain random cells of this
spreadsheet have a background color of red. Is there anyway to go

down
each
row of the spreadsheet and filter out all the rows that have a cell

with
the
background color of red? The colored cells are located in different

columns.
I need to filter/sort and get rid of the rows that have no color at

all.
(that is - the colored cells are of importance)

I tried to seach for similar problems on here but found none. Any

help
would be appreciated.

Thanks,
Terrel






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Filtering by Cell Background Color

I can work around the not-deleting by making a copy of the sheet and then
running the code on it.

The code you provided was of great help. Thank you again.

"Tom Ogilvy" wrote:

Sub DeleteRows()
Dim lastrow as long, lastColumn as Long
Dim i as Long, j as Long
Dim bColored as Boolean
LastRow = 500
LastColumn = 26
for i = lastrow to 2 step -1
bcolored = False
for j = 1 to lastcolumn
if cells(i,j).Interior.ColorIndex < xlNone then
bcolored = True
exit for
end if
Next
if not bColored then
rows(i).Delete
End if
Next
End if

Set values for LastRow and LastColumn
--
Regards,
Tom Ogilvy


"LoboNetwork" wrote in message
...
Hello,

I have a large populated spreadsheet. Certain random cells of this
spreadsheet have a background color of red. Is there anyway to go down

each
row of the spreadsheet and filter out all the rows that have a cell with

the
background color of red? The colored cells are located in different

columns.
I need to filter/sort and get rid of the rows that have no color at all.
(that is - the colored cells are of importance)

I tried to seach for similar problems on here but found none. Any help
would be appreciated.

Thanks,
Terrel






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Filtering by Cell Background Color

Hi Terrel,
you can use user defined function like this.

Function tellmecolor(colorcell As Range) As Integer
tellmecolor = colorcell.Interior.ColorIndex
End Function

to get the colorindexes of cells and then use filter on the colorindex
numbers.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Filtering by Cell Background Color

Thanks.

"Roman" wrote:

Hi Terrel,
you can use user defined function like this.

Function tellmecolor(colorcell As Range) As Integer
tellmecolor = colorcell.Interior.ColorIndex
End Function

to get the colorindexes of cells and then use filter on the colorindex
numbers.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Filtering by Cell Background Color

The data I wish to filter exists in a single column (e4:e900) of two
differing colors. I have used the user defined function:

Function tellmecolor(colorcell As Range) As Integer
tellmecolor = colorcell.Interior.ColorIndex
End Function

to define the values of my interior cell colors thus:
red = 3
green = 10

Now I can't figure out how to use the user defined function to place an
integer in each cell within the (e4:e900) range so I can filter out the 10's.

The user defined function as written only places a single integer in the
cell selected. Any help would be greatly appreciated.

haznavy

"LoboNetwork" wrote:

Hello,

I have a large populated spreadsheet. Certain random cells of this
spreadsheet have a background color of red. Is there anyway to go down each
row of the spreadsheet and filter out all the rows that have a cell with the
background color of red? The colored cells are located in different columns.
I need to filter/sort and get rid of the rows that have no color at all.
(that is - the colored cells are of importance)

I tried to seach for similar problems on here but found none. Any help
would be appreciated.

Thanks,
Terrel

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Filtering by Cell Background Color

Insert a new column F.

Select F4:F900
Type this:
=tellmecolor(e4)
and hit ctrl-enter to fill the selection with the formula (excel will adjust the
row number).

haznavy wrote:

The data I wish to filter exists in a single column (e4:e900) of two
differing colors. I have used the user defined function:

Function tellmecolor(colorcell As Range) As Integer
tellmecolor = colorcell.Interior.ColorIndex
End Function

to define the values of my interior cell colors thus:
red = 3
green = 10

Now I can't figure out how to use the user defined function to place an
integer in each cell within the (e4:e900) range so I can filter out the 10's.

The user defined function as written only places a single integer in the
cell selected. Any help would be greatly appreciated.

haznavy

"LoboNetwork" wrote:

Hello,

I have a large populated spreadsheet. Certain random cells of this
spreadsheet have a background color of red. Is there anyway to go down each
row of the spreadsheet and filter out all the rows that have a cell with the
background color of red? The colored cells are located in different columns.
I need to filter/sort and get rid of the rows that have no color at all.
(that is - the colored cells are of importance)

I tried to seach for similar problems on here but found none. Any help
would be appreciated.

Thanks,
Terrel


--

Dave Peterson
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Filtering by Cell Background Color

The data I wish to filter exists in a single column (e4:e900) of two
differing colors. I have used the user defined function:

Function tellmecolor(colorcell As Range) As Integer
tellmecolor = colorcell.Interior.ColorIndex
End Function

to define the values of my interior cell colors thus:
red = 3
green = 10

Now I can't figure out how to use the user defined function to place an
integer in each cell within the (e4:e900) range so I can filter out the
10's.


Dave gave you a Macro-As-Formula solution, but since you posted in the
excel.programming newsgroup, the possibility exists that you were looking
for a single function call to do all the work (for example, in response to
the click of a CommandButton). This modification to your function will do
that...

Function TellMeColor(ColorCells As Range) As Integer
Dim R As Range
For Each R In ColorCells
R.Value = R.Interior.ColorIndex
Next
End Function

If you go with the CommandButton activation method, here is what its Click
event would look like...

Private Sub CommandButton1_Click()
TellMeColor Range("E4:E900")
End Sub

for the fixed range you specified. If you wanted the function to operate on
a user defined selection, the Click event would look like this...

Private Sub CommandButton1_Click()
TellMeColor Selection
End Sub

Just highlight the cells of interest and click the button.

Rick



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel 2007 - Filtering by Cell Background Color NOT WORKING

MS 2007 allows you to filter by cell color, but it's not working correctly.
When I filter on a selected color the system doesn't filter all of the cells
with the color and it displays some cells with a totally different color.
Any ideas?
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel 2007 - Filtering by Cell Background Color NOT WORKING

Hi smierau

If you want send me a workbook with this problem private and
I will create a bug report if I can reproduce it

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"smierau" wrote in message ...
MS 2007 allows you to filter by cell color, but it's not working correctly.
When I filter on a selected color the system doesn't filter all of the cells
with the color and it displays some cells with a totally different color.
Any ideas?

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
Cell Background Color Joe Gieder Excel Worksheet Functions 4 July 15th 08 09:24 PM
cell background color and cell text color Jeff Klein Excel Worksheet Functions 1 November 1st 07 08:59 PM
Default Border, Font Color, and Cell Background Color Elijah Excel Discussion (Misc queries) 1 October 28th 05 04:10 PM
Cell Background Color Bob Excel Programming 2 February 1st 04 03:56 PM
Color of Cell Background Michael Kintner Excel Programming 2 January 6th 04 06:33 PM


All times are GMT +1. The time now is 03:33 AM.

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

About Us

"It's about Microsoft Excel"