PC Review


Reply
Thread Tools Rate Thread

Colors of Cells With Conditional Formatting

 
 
Faraz A. Qureshi
Guest
Posts: n/a
 
      17th Dec 2009
I have a code for selecting the cells with specific interior color be
selected as follows, however, how to add cells colored similarly but due to
conditional formatting, whether by the 1st, 2nd or any condition?

Sub SlctClrCel(CONTROL As IRibbonControl)
Dim CRange As Range
Dim A As Range
Dim B As Range
RETRY:
Set A = Application.InputBox("Select A Sample Cell With The Desired Interior
Color.", Type:=8)
Set B = Application.InputBox("Looking In Which Range?" & vbNewLine &
"Remember To Select Only The Necessary Cells", Type:=8)
For Each C In B
If C.Interior.ColorIndex = A.Interior.ColorIndex Then
If CRange Is Nothing Then
Set CRange = C
Else
Set CRange = Union(CRange, C)
End If
End If
Next
If Not CRange Is Nothing Then
CRange.Select
Else
MsgBox ("None Found!")
End If
End Sub

--
Thanx in advance,
Best Regards,

Faraz
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      17th Dec 2009
Hi Faraz

Try the below function to get the color index of a conditional formatted cell.

Function GetCFColorIndex(c As Range) As Variant
Dim intCount As Integer, FC As FormatCondition, blnMatch As Boolean
If c.Count <> 1 Then Exit Function
For intCount = 1 To c.FormatConditions.Count
'Loop through each Contidional Formatting
Set FC = c.FormatConditions(intCount)
Application.Volatile
If FC.Type = 1 Then
'Handle Type1-xlExpression (If 'Cell Value Is')
Select Case FC.Operator
Case xlBetween '1
If c.Value >= GetCFV(FC.Formula1, c) And c.Value _
<= GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For
Case xlNotBetween '2
If c.Value < GetCFV(FC.Formula1, c) Or c.Value _
> GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For

Case xlEqual '3
If c.Value = GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
Case xlNotEqual '4
If c.Value <> GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
Case xlGreater '5
If c.Value > GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
Case xlGreaterEqual '6
If c.Value >= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
Case xlLess '7
If c.Value < GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
Case xlLessEqual '8
If c.Value <= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
End Select
Else
'Handle Type2-xlExternal (If 'Formula Is')
If Evaluate(Application.ConvertFormula( _
Application.ConvertFormula(FC.Formula1, xlA1, xlR1C1), _
xlR1C1, xlA1, , c)) Then blnMatch = True: Exit For
End If
Next

If blnMatch Then GetCFColorIndex = FC.Interior.ColorIndex
End Functio
'-------------------------------------------------------------------------------
Function GetCFV(strData As Variant, c As Range)
'Get text string or numeric from CF formula
If IsNumeric(strData) Then
GetCFV = CDbl(strData)
ElseIf InStr(strData, Chr(34)) Then
GetCFV = Mid(strData, 3, Len(strData) - 3)
Else
GetCFV = Range(Mid(Application.ConvertFormula( _
Application.ConvertFormula(strData, xlA1, xlR1C1), _
xlR1C1, xlA1, , c), 2))
End If
End Functio
'-------------------------------------------------------------------------------


--
Jacob


"Faraz A. Qureshi" wrote:

> I have a code for selecting the cells with specific interior color be
> selected as follows, however, how to add cells colored similarly but due to
> conditional formatting, whether by the 1st, 2nd or any condition?
>
> Sub SlctClrCel(CONTROL As IRibbonControl)
> Dim CRange As Range
> Dim A As Range
> Dim B As Range
> RETRY:
> Set A = Application.InputBox("Select A Sample Cell With The Desired Interior
> Color.", Type:=8)
> Set B = Application.InputBox("Looking In Which Range?" & vbNewLine &
> "Remember To Select Only The Necessary Cells", Type:=8)
> For Each C In B
> If C.Interior.ColorIndex = A.Interior.ColorIndex Then
> If CRange Is Nothing Then
> Set CRange = C
> Else
> Set CRange = Union(CRange, C)
> End If
> End If
> Next
> If Not CRange Is Nothing Then
> CRange.Select
> Else
> MsgBox ("None Found!")
> End If
> End Sub
>
> --
> Thanx in advance,
> Best Regards,
>
> Faraz

 
Reply With Quote
 
Faraz A. Qureshi
Guest
Posts: n/a
 
      17th Dec 2009
Nice 2 hear from u after such a longtime pal!
Sure had been busy myself!
By the way Your recommended Function no doubt presents a good way but the
result changes to "1" everytime I carryout a step after inserting the UDF
GetCFColorIndex, any reason?

By the way, instead of a function any idea for a procedure?
--
Thanx in advance,
Best Regards,

Faraz


"Jacob Skaria" wrote:

> Hi Faraz
>
> Try the below function to get the color index of a conditional formatted cell.
>
> Function GetCFColorIndex(c As Range) As Variant
> Dim intCount As Integer, FC As FormatCondition, blnMatch As Boolean
> If c.Count <> 1 Then Exit Function
> For intCount = 1 To c.FormatConditions.Count
> 'Loop through each Contidional Formatting
> Set FC = c.FormatConditions(intCount)
> Application.Volatile
> If FC.Type = 1 Then
> 'Handle Type1-xlExpression (If 'Cell Value Is')
> Select Case FC.Operator
> Case xlBetween '1
> If c.Value >= GetCFV(FC.Formula1, c) And c.Value _
> <= GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For
> Case xlNotBetween '2
> If c.Value < GetCFV(FC.Formula1, c) Or c.Value _
> > GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For

> Case xlEqual '3
> If c.Value = GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> Case xlNotEqual '4
> If c.Value <> GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> Case xlGreater '5
> If c.Value > GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> Case xlGreaterEqual '6
> If c.Value >= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> Case xlLess '7
> If c.Value < GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> Case xlLessEqual '8
> If c.Value <= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> End Select
> Else
> 'Handle Type2-xlExternal (If 'Formula Is')
> If Evaluate(Application.ConvertFormula( _
> Application.ConvertFormula(FC.Formula1, xlA1, xlR1C1), _
> xlR1C1, xlA1, , c)) Then blnMatch = True: Exit For
> End If
> Next
>
> If blnMatch Then GetCFColorIndex = FC.Interior.ColorIndex
> End Function
> '-------------------------------------------------------------------------------
> Function GetCFV(strData As Variant, c As Range)
> 'Get text string or numeric from CF formula
> If IsNumeric(strData) Then
> GetCFV = CDbl(strData)
> ElseIf InStr(strData, Chr(34)) Then
> GetCFV = Mid(strData, 3, Len(strData) - 3)
> Else
> GetCFV = Range(Mid(Application.ConvertFormula( _
> Application.ConvertFormula(strData, xlA1, xlR1C1), _
> xlR1C1, xlA1, , c), 2))
> End If
> End Function
> '-------------------------------------------------------------------------------
>
>
> --
> Jacob
>
>
> "Faraz A. Qureshi" wrote:
>
> > I have a code for selecting the cells with specific interior color be
> > selected as follows, however, how to add cells colored similarly but due to
> > conditional formatting, whether by the 1st, 2nd or any condition?
> >
> > Sub SlctClrCel(CONTROL As IRibbonControl)
> > Dim CRange As Range
> > Dim A As Range
> > Dim B As Range
> > RETRY:
> > Set A = Application.InputBox("Select A Sample Cell With The Desired Interior
> > Color.", Type:=8)
> > Set B = Application.InputBox("Looking In Which Range?" & vbNewLine &
> > "Remember To Select Only The Necessary Cells", Type:=8)
> > For Each C In B
> > If C.Interior.ColorIndex = A.Interior.ColorIndex Then
> > If CRange Is Nothing Then
> > Set CRange = C
> > Else
> > Set CRange = Union(CRange, C)
> > End If
> > End If
> > Next
> > If Not CRange Is Nothing Then
> > CRange.Select
> > Else
> > MsgBox ("None Found!")
> > End If
> > End Sub
> >
> > --
> > Thanx in advance,
> > Best Regards,
> >
> > Faraz

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      18th Dec 2009
Paste both functions in a module and try with the macro.

The below will return the colorindex of cell D5. Try conditional formatting
cell D5 with fill color red and run the macro both with the condition and
without....If the cell is colored due to CF the macro will return the
colorindex applied...

Sub Macro1()
MsgBox GetCFColorIndex(Range("D5"))
End Sub


--
Jacob


"Faraz A. Qureshi" wrote:

> Nice 2 hear from u after such a longtime pal!
> Sure had been busy myself!
> By the way Your recommended Function no doubt presents a good way but the
> result changes to "1" everytime I carryout a step after inserting the UDF
> GetCFColorIndex, any reason?
>
> By the way, instead of a function any idea for a procedure?
> --
> Thanx in advance,
> Best Regards,
>
> Faraz
>
>
> "Jacob Skaria" wrote:
>
> > Hi Faraz
> >
> > Try the below function to get the color index of a conditional formatted cell.
> >
> > Function GetCFColorIndex(c As Range) As Variant
> > Dim intCount As Integer, FC As FormatCondition, blnMatch As Boolean
> > If c.Count <> 1 Then Exit Function
> > For intCount = 1 To c.FormatConditions.Count
> > 'Loop through each Contidional Formatting
> > Set FC = c.FormatConditions(intCount)
> > Application.Volatile
> > If FC.Type = 1 Then
> > 'Handle Type1-xlExpression (If 'Cell Value Is')
> > Select Case FC.Operator
> > Case xlBetween '1
> > If c.Value >= GetCFV(FC.Formula1, c) And c.Value _
> > <= GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For
> > Case xlNotBetween '2
> > If c.Value < GetCFV(FC.Formula1, c) Or c.Value _
> > > GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For

> > Case xlEqual '3
> > If c.Value = GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > Case xlNotEqual '4
> > If c.Value <> GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > Case xlGreater '5
> > If c.Value > GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > Case xlGreaterEqual '6
> > If c.Value >= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > Case xlLess '7
> > If c.Value < GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > Case xlLessEqual '8
> > If c.Value <= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > End Select
> > Else
> > 'Handle Type2-xlExternal (If 'Formula Is')
> > If Evaluate(Application.ConvertFormula( _
> > Application.ConvertFormula(FC.Formula1, xlA1, xlR1C1), _
> > xlR1C1, xlA1, , c)) Then blnMatch = True: Exit For
> > End If
> > Next
> >
> > If blnMatch Then GetCFColorIndex = FC.Interior.ColorIndex
> > End Function
> > '-------------------------------------------------------------------------------
> > Function GetCFV(strData As Variant, c As Range)
> > 'Get text string or numeric from CF formula
> > If IsNumeric(strData) Then
> > GetCFV = CDbl(strData)
> > ElseIf InStr(strData, Chr(34)) Then
> > GetCFV = Mid(strData, 3, Len(strData) - 3)
> > Else
> > GetCFV = Range(Mid(Application.ConvertFormula( _
> > Application.ConvertFormula(strData, xlA1, xlR1C1), _
> > xlR1C1, xlA1, , c), 2))
> > End If
> > End Function
> > '-------------------------------------------------------------------------------
> >
> >
> > --
> > Jacob
> >
> >
> > "Faraz A. Qureshi" wrote:
> >
> > > I have a code for selecting the cells with specific interior color be
> > > selected as follows, however, how to add cells colored similarly but due to
> > > conditional formatting, whether by the 1st, 2nd or any condition?
> > >
> > > Sub SlctClrCel(CONTROL As IRibbonControl)
> > > Dim CRange As Range
> > > Dim A As Range
> > > Dim B As Range
> > > RETRY:
> > > Set A = Application.InputBox("Select A Sample Cell With The Desired Interior
> > > Color.", Type:=8)
> > > Set B = Application.InputBox("Looking In Which Range?" & vbNewLine &
> > > "Remember To Select Only The Necessary Cells", Type:=8)
> > > For Each C In B
> > > If C.Interior.ColorIndex = A.Interior.ColorIndex Then
> > > If CRange Is Nothing Then
> > > Set CRange = C
> > > Else
> > > Set CRange = Union(CRange, C)
> > > End If
> > > End If
> > > Next
> > > If Not CRange Is Nothing Then
> > > CRange.Select
> > > Else
> > > MsgBox ("None Found!")
> > > End If
> > > End Sub
> > >
> > > --
> > > Thanx in advance,
> > > Best Regards,
> > >
> > > Faraz

 
Reply With Quote
 
Faraz A. Qureshi
Guest
Posts: n/a
 
      18th Dec 2009
Dear Jacob,

Problem still exists. Can't describe the same in words. Emailing you a
sample file on your yahoo's jacs address. Please c if u can help me!
Sure am thankful 4 all your help pal!
--
Thanx in advance,
Best Regards,

Faraz


"Jacob Skaria" wrote:

> Paste both functions in a module and try with the macro.
>
> The below will return the colorindex of cell D5. Try conditional formatting
> cell D5 with fill color red and run the macro both with the condition and
> without....If the cell is colored due to CF the macro will return the
> colorindex applied...
>
> Sub Macro1()
> MsgBox GetCFColorIndex(Range("D5"))
> End Sub
>
>
> --
> Jacob
>
>
> "Faraz A. Qureshi" wrote:
>
> > Nice 2 hear from u after such a longtime pal!
> > Sure had been busy myself!
> > By the way Your recommended Function no doubt presents a good way but the
> > result changes to "1" everytime I carryout a step after inserting the UDF
> > GetCFColorIndex, any reason?
> >
> > By the way, instead of a function any idea for a procedure?
> > --
> > Thanx in advance,
> > Best Regards,
> >
> > Faraz
> >
> >
> > "Jacob Skaria" wrote:
> >
> > > Hi Faraz
> > >
> > > Try the below function to get the color index of a conditional formatted cell.
> > >
> > > Function GetCFColorIndex(c As Range) As Variant
> > > Dim intCount As Integer, FC As FormatCondition, blnMatch As Boolean
> > > If c.Count <> 1 Then Exit Function
> > > For intCount = 1 To c.FormatConditions.Count
> > > 'Loop through each Contidional Formatting
> > > Set FC = c.FormatConditions(intCount)
> > > Application.Volatile
> > > If FC.Type = 1 Then
> > > 'Handle Type1-xlExpression (If 'Cell Value Is')
> > > Select Case FC.Operator
> > > Case xlBetween '1
> > > If c.Value >= GetCFV(FC.Formula1, c) And c.Value _
> > > <= GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For
> > > Case xlNotBetween '2
> > > If c.Value < GetCFV(FC.Formula1, c) Or c.Value _
> > > > GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For
> > > Case xlEqual '3
> > > If c.Value = GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > Case xlNotEqual '4
> > > If c.Value <> GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > Case xlGreater '5
> > > If c.Value > GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > Case xlGreaterEqual '6
> > > If c.Value >= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > Case xlLess '7
> > > If c.Value < GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > Case xlLessEqual '8
> > > If c.Value <= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > End Select
> > > Else
> > > 'Handle Type2-xlExternal (If 'Formula Is')
> > > If Evaluate(Application.ConvertFormula( _
> > > Application.ConvertFormula(FC.Formula1, xlA1, xlR1C1), _
> > > xlR1C1, xlA1, , c)) Then blnMatch = True: Exit For
> > > End If
> > > Next
> > >
> > > If blnMatch Then GetCFColorIndex = FC.Interior.ColorIndex
> > > End Function
> > > '-------------------------------------------------------------------------------
> > > Function GetCFV(strData As Variant, c As Range)
> > > 'Get text string or numeric from CF formula
> > > If IsNumeric(strData) Then
> > > GetCFV = CDbl(strData)
> > > ElseIf InStr(strData, Chr(34)) Then
> > > GetCFV = Mid(strData, 3, Len(strData) - 3)
> > > Else
> > > GetCFV = Range(Mid(Application.ConvertFormula( _
> > > Application.ConvertFormula(strData, xlA1, xlR1C1), _
> > > xlR1C1, xlA1, , c), 2))
> > > End If
> > > End Function
> > > '-------------------------------------------------------------------------------
> > >
> > >
> > > --
> > > Jacob
> > >
> > >
> > > "Faraz A. Qureshi" wrote:
> > >
> > > > I have a code for selecting the cells with specific interior color be
> > > > selected as follows, however, how to add cells colored similarly but due to
> > > > conditional formatting, whether by the 1st, 2nd or any condition?
> > > >
> > > > Sub SlctClrCel(CONTROL As IRibbonControl)
> > > > Dim CRange As Range
> > > > Dim A As Range
> > > > Dim B As Range
> > > > RETRY:
> > > > Set A = Application.InputBox("Select A Sample Cell With The Desired Interior
> > > > Color.", Type:=8)
> > > > Set B = Application.InputBox("Looking In Which Range?" & vbNewLine &
> > > > "Remember To Select Only The Necessary Cells", Type:=8)
> > > > For Each C In B
> > > > If C.Interior.ColorIndex = A.Interior.ColorIndex Then
> > > > If CRange Is Nothing Then
> > > > Set CRange = C
> > > > Else
> > > > Set CRange = Union(CRange, C)
> > > > End If
> > > > End If
> > > > Next
> > > > If Not CRange Is Nothing Then
> > > > CRange.Select
> > > > Else
> > > > MsgBox ("None Found!")
> > > > End If
> > > > End Sub
> > > >
> > > > --
> > > > Thanx in advance,
> > > > Best Regards,
> > > >
> > > > Faraz

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      18th Dec 2009
Faraz; I should have mentioned the code works fine only in XL2003.
Conditional formatting has changed a lot in XL2007 and I havent tested this
for XL2007.

--
Jacob


"Faraz A. Qureshi" wrote:

> Dear Jacob,
>
> Problem still exists. Can't describe the same in words. Emailing you a
> sample file on your yahoo's jacs address. Please c if u can help me!
> Sure am thankful 4 all your help pal!
> --
> Thanx in advance,
> Best Regards,
>
> Faraz
>
>
> "Jacob Skaria" wrote:
>
> > Paste both functions in a module and try with the macro.
> >
> > The below will return the colorindex of cell D5. Try conditional formatting
> > cell D5 with fill color red and run the macro both with the condition and
> > without....If the cell is colored due to CF the macro will return the
> > colorindex applied...
> >
> > Sub Macro1()
> > MsgBox GetCFColorIndex(Range("D5"))
> > End Sub
> >
> >
> > --
> > Jacob
> >
> >
> > "Faraz A. Qureshi" wrote:
> >
> > > Nice 2 hear from u after such a longtime pal!
> > > Sure had been busy myself!
> > > By the way Your recommended Function no doubt presents a good way but the
> > > result changes to "1" everytime I carryout a step after inserting the UDF
> > > GetCFColorIndex, any reason?
> > >
> > > By the way, instead of a function any idea for a procedure?
> > > --
> > > Thanx in advance,
> > > Best Regards,
> > >
> > > Faraz
> > >
> > >
> > > "Jacob Skaria" wrote:
> > >
> > > > Hi Faraz
> > > >
> > > > Try the below function to get the color index of a conditional formatted cell.
> > > >
> > > > Function GetCFColorIndex(c As Range) As Variant
> > > > Dim intCount As Integer, FC As FormatCondition, blnMatch As Boolean
> > > > If c.Count <> 1 Then Exit Function
> > > > For intCount = 1 To c.FormatConditions.Count
> > > > 'Loop through each Contidional Formatting
> > > > Set FC = c.FormatConditions(intCount)
> > > > Application.Volatile
> > > > If FC.Type = 1 Then
> > > > 'Handle Type1-xlExpression (If 'Cell Value Is')
> > > > Select Case FC.Operator
> > > > Case xlBetween '1
> > > > If c.Value >= GetCFV(FC.Formula1, c) And c.Value _
> > > > <= GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For
> > > > Case xlNotBetween '2
> > > > If c.Value < GetCFV(FC.Formula1, c) Or c.Value _
> > > > > GetCFV(FC.Formula2, c) Then blnMatch = True: Exit For
> > > > Case xlEqual '3
> > > > If c.Value = GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > > Case xlNotEqual '4
> > > > If c.Value <> GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > > Case xlGreater '5
> > > > If c.Value > GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > > Case xlGreaterEqual '6
> > > > If c.Value >= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > > Case xlLess '7
> > > > If c.Value < GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > > Case xlLessEqual '8
> > > > If c.Value <= GetCFV(FC.Formula1, c) Then blnMatch = True: Exit For
> > > > End Select
> > > > Else
> > > > 'Handle Type2-xlExternal (If 'Formula Is')
> > > > If Evaluate(Application.ConvertFormula( _
> > > > Application.ConvertFormula(FC.Formula1, xlA1, xlR1C1), _
> > > > xlR1C1, xlA1, , c)) Then blnMatch = True: Exit For
> > > > End If
> > > > Next
> > > >
> > > > If blnMatch Then GetCFColorIndex = FC.Interior.ColorIndex
> > > > End Function
> > > > '-------------------------------------------------------------------------------
> > > > Function GetCFV(strData As Variant, c As Range)
> > > > 'Get text string or numeric from CF formula
> > > > If IsNumeric(strData) Then
> > > > GetCFV = CDbl(strData)
> > > > ElseIf InStr(strData, Chr(34)) Then
> > > > GetCFV = Mid(strData, 3, Len(strData) - 3)
> > > > Else
> > > > GetCFV = Range(Mid(Application.ConvertFormula( _
> > > > Application.ConvertFormula(strData, xlA1, xlR1C1), _
> > > > xlR1C1, xlA1, , c), 2))
> > > > End If
> > > > End Function
> > > > '-------------------------------------------------------------------------------
> > > >
> > > >
> > > > --
> > > > Jacob
> > > >
> > > >
> > > > "Faraz A. Qureshi" wrote:
> > > >
> > > > > I have a code for selecting the cells with specific interior color be
> > > > > selected as follows, however, how to add cells colored similarly but due to
> > > > > conditional formatting, whether by the 1st, 2nd or any condition?
> > > > >
> > > > > Sub SlctClrCel(CONTROL As IRibbonControl)
> > > > > Dim CRange As Range
> > > > > Dim A As Range
> > > > > Dim B As Range
> > > > > RETRY:
> > > > > Set A = Application.InputBox("Select A Sample Cell With The Desired Interior
> > > > > Color.", Type:=8)
> > > > > Set B = Application.InputBox("Looking In Which Range?" & vbNewLine &
> > > > > "Remember To Select Only The Necessary Cells", Type:=8)
> > > > > For Each C In B
> > > > > If C.Interior.ColorIndex = A.Interior.ColorIndex Then
> > > > > If CRange Is Nothing Then
> > > > > Set CRange = C
> > > > > Else
> > > > > Set CRange = Union(CRange, C)
> > > > > End If
> > > > > End If
> > > > > Next
> > > > > If Not CRange Is Nothing Then
> > > > > CRange.Select
> > > > > Else
> > > > > MsgBox ("None Found!")
> > > > > End If
> > > > > End Sub
> > > > >
> > > > > --
> > > > > Thanx in advance,
> > > > > Best Regards,
> > > > >
> > > > > Faraz

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Colors of Cells set by Conditional Formatting RobFJ Microsoft Excel Worksheet Functions 2 16th Feb 2010 01:01 PM
Conditional Formatting Based on Colors in a Horz Range of Cells DOUG ECKERT Microsoft Excel Misc 10 19th Dec 2008 02:29 PM
Conditional Formatting - Colors =?Utf-8?B?V2hhcmZSdW5uZXI=?= Microsoft Access Forms 3 9th Apr 2007 10:04 PM
Conditional Formatting in 6 colors =?Utf-8?B?U3Rlcmxpbmc=?= Microsoft Excel Misc 1 6th Oct 2006 11:22 PM
conditional formatting colors tania Microsoft Excel Misc 3 10th Aug 2004 05:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:24 PM.