Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Selecting Cells

Is there a way to select all cells in a sheet except the rows and columns
that contain the words "Variance" and "Total"?

For example, rows that contain "Total Revenues" should not be selected.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Selecting Cells

This is done in three steps:

1. clear the background color in UsedRange. Then search for cells
containing your words and mark the entire column and row in red

2. loop thru UsedRange again, building another range, better_dead, of those
cells that are not red.

3. clear the background color and select better_dead

Public red As range
Public better_dead As range
Sub step1()

'gsnu

Dim r As range

Cells.Interior.ColorIndex = xlNone
v1 = "Variance"
v2 = "Total"
For Each r In ActiveSheet.UsedRange
v = r.Value
If InStr(v, v1) < 0 Or InStr(v, v2) < 0 Then
r.EntireRow.Interior.ColorIndex = 3
r.EntireColumn.Interior.ColorIndex = 3
End If
Next

For Each r In ActiveSheet.UsedRange
If r.Interior.ColorIndex = 3 Then
Else
If better_dead Is Nothing Then
Set better_dead = r
Else
Set better_dead = Union(better_dead, r)
End If
End If
Next

Cells.Interior.ColorIndex = xlNone
If better_dead Is Nothing Then
Else
better_dead.Select
End If
End sub
--
Gary's Student


"Steve" wrote:

Is there a way to select all cells in a sheet except the rows and columns
that contain the words "Variance" and "Total"?

For example, rows that contain "Total Revenues" should not be selected.

Thanks

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
Selecting multiple cells, I can't see the cells highlighted ET Excel Discussion (Misc queries) 1 August 1st 08 03:20 PM
How to change shade of cells when selecting multiple cells abrummet Excel Discussion (Misc queries) 3 September 6th 07 11:42 AM
By selecting cells adjacent to cells tally sheet tom Excel Worksheet Functions 2 September 20th 06 07:09 PM
Selecting 10 cells downwards [email protected] Excel Programming 2 September 6th 06 12:26 PM
selecting cells Wazooli Excel Discussion (Misc queries) 3 January 11th 05 09:53 PM


All times are GMT +1. The time now is 05:39 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"