Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Cell Background Color | Excel Worksheet Functions | |||
cell background color and cell text color | Excel Worksheet Functions | |||
Default Border, Font Color, and Cell Background Color | Excel Discussion (Misc queries) | |||
Cell Background Color | Excel Programming | |||
Color of Cell Background | Excel Programming |