Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Define Range based on cell color

Is it possible to define a range based on cell color? What I'd like to do is
hide/unhide all columns containing cells with the background colors 34 and
37. After reading Dave Pearson's information, it seems possible but I have
no idea how to make it work.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Define Range based on cell color

Hi
one way:
- using Dave's information add a helper column showing the colorindex
- apply an Autofilter to show/hide the desired rows

--
Regards
Frank Kabel
Frankfurt, Germany

StephanieH wrote:
Is it possible to define a range based on cell color? What I'd like
to do is hide/unhide all columns containing cells with the background
colors 34 and
37. After reading Dave Pearson's information, it seems possible but
I have no idea how to make it work.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Define Range based on cell color

Sub tester1()
Columns.Hidden = False
For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 37 Or cell.Interior.ColorIndex = 34 Then
cell.EntireColumn.Hidden = True
End If
Next
End Sub

--
Regards,
Tom Ogilvy




"StephanieH" wrote in message
...
Is it possible to define a range based on cell color? What I'd like to do

is
hide/unhide all columns containing cells with the background colors 34 and
37. After reading Dave Pearson's information, it seems possible but I

have
no idea how to make it work.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Define Range based on cell color

Thanks Tom.
It does hide the columns, but then appears to keep searching for additional
cells? I get the hour glass and it doesn't really stop searching. When I
hit Esc and Debug, the END IF statement is highlighted.

"Tom Ogilvy" wrote:

Sub tester1()
Columns.Hidden = False
For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 37 Or cell.Interior.ColorIndex = 34 Then
cell.EntireColumn.Hidden = True
End If
Next
End Sub

--
Regards,
Tom Ogilvy




"StephanieH" wrote in message
...
Is it possible to define a range based on cell color? What I'd like to do

is
hide/unhide all columns containing cells with the background colors 34 and
37. After reading Dave Pearson's information, it seems possible but I

have
no idea how to make it work.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Define Range based on cell color

It is looking at every cell in the UsedRange (you didn't say where to look).
If you have a large UsedRange, then it may take a while. If there is a
smaller area it can search, then you can change it to search that

rather than
For Each cell In ActiveSheet.UsedRange

perhaps

For Each cell In ActiveSheet.Rows(1).Cells

for just the first row as an example.

--
Regards,
Tom Ogilvy

"StephanieH" wrote in message
...
Thanks Tom.
It does hide the columns, but then appears to keep searching for

additional
cells? I get the hour glass and it doesn't really stop searching. When I
hit Esc and Debug, the END IF statement is highlighted.

"Tom Ogilvy" wrote:

Sub tester1()
Columns.Hidden = False
For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 37 Or cell.Interior.ColorIndex = 34 Then
cell.EntireColumn.Hidden = True
End If
Next
End Sub

--
Regards,
Tom Ogilvy




"StephanieH" wrote in message
...
Is it possible to define a range based on cell color? What I'd like

to do
is
hide/unhide all columns containing cells with the background colors 34

and
37. After reading Dave Pearson's information, it seems possible but I

have
no idea how to make it work.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Define Range based on cell color

Awesome. You're right, it was searching through the whole sheet. I went in
an deleted all unused columns/rows so hopefully it won't recognize that space
as "used".

Specifying a row made all the difference.

Thanks again..

"Tom Ogilvy" wrote:

It is looking at every cell in the UsedRange (you didn't say where to look).
If you have a large UsedRange, then it may take a while. If there is a
smaller area it can search, then you can change it to search that

rather than
For Each cell In ActiveSheet.UsedRange

perhaps

For Each cell In ActiveSheet.Rows(1).Cells

for just the first row as an example.

--
Regards,
Tom Ogilvy

"StephanieH" wrote in message
...
Thanks Tom.
It does hide the columns, but then appears to keep searching for

additional
cells? I get the hour glass and it doesn't really stop searching. When I
hit Esc and Debug, the END IF statement is highlighted.

"Tom Ogilvy" wrote:

Sub tester1()
Columns.Hidden = False
For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 37 Or cell.Interior.ColorIndex = 34 Then
cell.EntireColumn.Hidden = True
End If
Next
End Sub

--
Regards,
Tom Ogilvy




"StephanieH" wrote in message
...
Is it possible to define a range based on cell color? What I'd like

to do
is
hide/unhide all columns containing cells with the background colors 34

and
37. After reading Dave Pearson's information, it seems possible but I
have
no idea how to make it work.






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Define Range based on cell color

Once you delete entirerows and columns, then you need to save the workbook
for the UsedRange to be "recalculated"

Debra Dalgleish has instructions:
http://www.contextures.com/xlfaqApp.html#Unused

--
Regards,
Tom Ogilvy



"StephanieH" wrote in message
...
Awesome. You're right, it was searching through the whole sheet. I went

in
an deleted all unused columns/rows so hopefully it won't recognize that

space
as "used".

Specifying a row made all the difference.

Thanks again..

"Tom Ogilvy" wrote:

It is looking at every cell in the UsedRange (you didn't say where to

look).
If you have a large UsedRange, then it may take a while. If there is a
smaller area it can search, then you can change it to search that

rather than
For Each cell In ActiveSheet.UsedRange

perhaps

For Each cell In ActiveSheet.Rows(1).Cells

for just the first row as an example.

--
Regards,
Tom Ogilvy

"StephanieH" wrote in message
...
Thanks Tom.
It does hide the columns, but then appears to keep searching for

additional
cells? I get the hour glass and it doesn't really stop searching.

When I
hit Esc and Debug, the END IF statement is highlighted.

"Tom Ogilvy" wrote:

Sub tester1()
Columns.Hidden = False
For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 37 Or cell.Interior.ColorIndex = 34

Then
cell.EntireColumn.Hidden = True
End If
Next
End Sub

--
Regards,
Tom Ogilvy




"StephanieH" wrote in message
...
Is it possible to define a range based on cell color? What I'd

like
to do
is
hide/unhide all columns containing cells with the background

colors 34
and
37. After reading Dave Pearson's information, it seems possible

but I
have
no idea how to make it work.








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
How to Color a Cell Based on a Range of Cells with Colors ron weasley Excel Worksheet Functions 1 January 13th 10 01:05 AM
How to define a charts range based on the value of a cell chris Excel Discussion (Misc queries) 1 December 2nd 09 04:34 PM
Formatting the color of a range of cells based on the value of one cell [email protected] Excel Worksheet Functions 3 October 20th 06 07:04 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM
Define a Dynamic Range Based on an Index Mike Roberto Excel Programming 4 August 5th 04 02:02 PM


All times are GMT +1. The time now is 01:58 AM.

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"