Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default identify consecutive columns they are coloured

Hi,

Does anyone know whether there is a way to identify within a range of
F1:CU:5000, which columns is coloured consecutively? (ie. I want to
see which row is coloured in Red from F to CU Throughout.)

Thanks.
Elaine.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default identify consecutive columns they are coloured

Sub FindRed()
Dim rng as Range, rng1 as Range
Dim cell as Range
set rng = Range("F1:CU5000")
for each cell in rng
if cell.interior.colorIndex = 3 then
if rng1 is nothing then
set rng1 = cell
else
set rng1 = union(rng1,cell)
end if
end if
Next
if not rng1 is nothing then
rng1.select
end if
End Sub

--
Regards,
Tom Ogilvy

"elaine" wrote:

Hi,

Does anyone know whether there is a way to identify within a range of
F1:CU:5000, which columns is coloured consecutively? (ie. I want to
see which row is coloured in Red from F to CU Throughout.)

Thanks.
Elaine.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default identify consecutive columns they are coloured

Elaine,
Try this:

Private Sub CommandButton2_Click()
Dim CompleteRows As Range

Const INDEX_RED As Long = 3

Set CompleteRows = GetCompleteColouredRows(Range("C6:G8"), INDEX_RED)

If Not CompleteRows Is Nothing Then
MsgBox CompleteRows.Address
Else
MsgBox "No complete rows coloured"
End If

End Sub

Private Function GetCompleteColouredRows(CheckRange As Range,
ColourIndexToMatch As Long) As Range
Dim i As Long
Dim MatchedRange As Range

With CheckRange
For i = 1 To .Rows.Count
If .Rows(i).Interior.ColorIndex = ColourIndexToMatch Then
If MatchedRange Is Nothing Then
Set MatchedRange = .Cells(i, 1)
Else
Set MatchedRange = Union(MatchedRange, .Cells(i, 1))
End If
End If
Next
End With

Set GetCompleteColouredRows = MatchedRange

End Function

NickHK

"elaine" wrote in message
oups.com...
Hi,

Does anyone know whether there is a way to identify within a range of
F1:CU:5000, which columns is coloured consecutively? (ie. I want to
see which row is coloured in Red from F to CU Throughout.)

Thanks.
Elaine.



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
Countif non consecutive columns shamor New Users to Excel 8 May 31st 08 09:14 PM
Count non consecutive columns [email protected] Excel Worksheet Functions 7 May 23rd 06 03:24 PM
In Excel, print non-consecutive columns. kwm5321 Excel Discussion (Misc queries) 1 May 3rd 06 06:33 PM
adding three consecutive columns Darin Gibson Excel Worksheet Functions 1 November 22nd 05 08:50 PM
how do i add consecutive columns in excel ? debi Excel Discussion (Misc queries) 1 October 13th 05 06:11 PM


All times are GMT +1. The time now is 08:49 PM.

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"