PC Review


Reply
Thread Tools Rate Thread

Cell Highlighting

 
 
=?Utf-8?B?cGhtY2tlZXZlcg==?=
Guest
Posts: n/a
 
      31st Oct 2006

Hello,
I need the data in column C to be highlighted when rows begin with 'ign' and
'leg' in column A and have identical ID codes in column B.

Here is a 'cut and paste' from the worksheet (The XXX is just placeholders
to demonstrate; and the spacing between the rows is for clarity).

A B C D E
1 ign ABGN XXX XXX VA
2 leg ABGN XXX XXX *

3 ign ABVL XXX XXX KS
4 leg ABVL XXX XXX *

5 leg ADA XXX XXX *

6 ign ADAM XXX XXX OH
7 leg ADAM XXX XXX *

8 ign ADAR XXX XXX OH
9 leg ADAR XXX XXX *

10 ign AHSK XXX XXX NC
11 leg AHSK XXX XXX *

12 ign ALDN XXX XXX KS
13 leg ALDN XXX XXX *

The code below is highlighting cells e1 and e2, e3 and e4, which is correct
because columns A and B meet the criteria.

And cell e5 is not highlighted, which is also correct because it does not
meet the criteria.

However, the highlight is not being picked up at cells e6 and e7, e8 and e9,
e10 and e11, and e12 and e13, which it should because Column A and B fit the
criteria for these matches, ign and leg and identical id code.

Can you please, pleasssssse help me with this code. Thank you in advance.

phmckeever


Range("A1").Select
Set Record1 = Range("$b2")
Set Record2 = Range("$b3")
Range("A1").Select

Do While (Record1 <> "")
If (Record1 = Record2) Then
IngRow = Record1.Row

strRow1 = Trim$(Str$(IngRow))
strRow2 = Trim$(Str$(IngRow + 1))

s = "=AND($A" & strRow1 & "=""ign"", " & _
"$A" & strRow2 & "=""leg""," & _
"$B" & strRow1 & "=$B" & strRow2 & ")"

if evaluate(s) = true then
Set rngAll = Range("$C" & strRow1 & ":$E" & strRow2)
rngAll.FormatConditions.Delete

For x = 1 To rngAll.Columns.Count

strFormula = "=AND($A" & strRow1 & "=""ign"", " & _
"$A" & strRow2 & "=""leg""," & _
"$B" & strRow1 & "=$B" & strRow2 & "," & _
rngAll.Cells(1, x).Address & "<>" & _
rngAll.Cells(2, x).Address & ")"

rngAll.Cells(1, x).Select
Selection.FormatConditions.Add _
Type:=xlExpression, Formula1:=strFormula
Selection.FormatConditions(1).Interior.ColorIndex = 6

rngAll.Cells(2, x).Select
Selection.FormatConditions.Add _
Type:=xlExpression, Formula1:=strFormula
Selection.FormatConditions(1).Interior.ColorIndex = 6

Next x

End if

End If

Set Record1 = Record1.Offset(2, 0)
Set Record2 = Record2.Offset(2, 0)

Loop
 
Reply With Quote
 
 
 
 
=?Utf-8?B?cGhtY2tlZXZlcg==?=
Guest
Posts: n/a
 
      31st Oct 2006


"phmckeever" wrote:

>
> Hello,
> I need the data in column E to be highlighted when rows begin with 'ign' and
> 'leg' in column A and have identical ID codes in column B.
>
> Here is a 'cut and paste' from the worksheet (The XXX is just placeholders
> to demonstrate; and the spacing between the rows is for clarity).
>
> A B C D E
> 1 ign ABGN XXX XXX VA
> 2 leg ABGN XXX XXX *
>
> 3 ign ABVL XXX XXX KS
> 4 leg ABVL XXX XXX *
>
> 5 leg ADA XXX XXX *
>
> 6 ign ADAM XXX XXX OH
> 7 leg ADAM XXX XXX *
>
> 8 ign ADAR XXX XXX OH
> 9 leg ADAR XXX XXX *
>
> 10 ign AHSK XXX XXX NC
> 11 leg AHSK XXX XXX *
>
> 12 ign ALDN XXX XXX KS
> 13 leg ALDN XXX XXX *
>
> The code below is highlighting cells e1 and e2, e3 and e4, which is correct
> because columns A and B meet the criteria.
>
> And cell e5 is not highlighted, which is also correct because it does not
> meet the criteria.
>
> However, the highlight is not being picked up at cells e6 and e7, e8 and e9,
> e10 and e11, and e12 and e13, which it should because Column A and B fit the
> criteria for these matches, ign and leg and identical id code.
>
> Can you please, pleasssssse help me with this code. Thank you in advance.
>
> phmckeever
>
>
> Range("A1").Select
> Set Record1 = Range("$b2")
> Set Record2 = Range("$b3")
> Range("A1").Select
>
> Do While (Record1 <> "")
> If (Record1 = Record2) Then
> IngRow = Record1.Row
>
> strRow1 = Trim$(Str$(IngRow))
> strRow2 = Trim$(Str$(IngRow + 1))
>
> s = "=AND($A" & strRow1 & "=""ign"", " & _
> "$A" & strRow2 & "=""leg""," & _
> "$B" & strRow1 & "=$B" & strRow2 & ")"
>
> if evaluate(s) = true then
> Set rngAll = Range("$C" & strRow1 & ":$E" & strRow2)
> rngAll.FormatConditions.Delete
>
> For x = 1 To rngAll.Columns.Count
>
> strFormula = "=AND($A" & strRow1 & "=""ign"", " & _
> "$A" & strRow2 & "=""leg""," & _
> "$B" & strRow1 & "=$B" & strRow2 & "," & _
> rngAll.Cells(1, x).Address & "<>" & _
> rngAll.Cells(2, x).Address & ")"
>
> rngAll.Cells(1, x).Select
> Selection.FormatConditions.Add _
> Type:=xlExpression, Formula1:=strFormula
> Selection.FormatConditions(1).Interior.ColorIndex = 6
>
> rngAll.Cells(2, x).Select
> Selection.FormatConditions.Add _
> Type:=xlExpression, Formula1:=strFormula
> Selection.FormatConditions(1).Interior.ColorIndex = 6
>
> Next x
>
> End if
>
> End If
>
> Set Record1 = Record1.Offset(2, 0)
> Set Record2 = Record2.Offset(2, 0)
>
> Loop

 
Reply With Quote
 
=?Utf-8?B?cGhtY2tlZXZlcg==?=
Guest
Posts: n/a
 
      31st Oct 2006
The first sentence after hello should read,

I need the data in column "E", not C.

"phmckeever" wrote:

>
> Hello,
> I need the data in column C to be highlighted when rows begin with 'ign' and
> 'leg' in column A and have identical ID codes in column B.
>
> Here is a 'cut and paste' from the worksheet (The XXX is just placeholders
> to demonstrate; and the spacing between the rows is for clarity).
>
> A B C D E
> 1 ign ABGN XXX XXX VA
> 2 leg ABGN XXX XXX *
>
> 3 ign ABVL XXX XXX KS
> 4 leg ABVL XXX XXX *
>
> 5 leg ADA XXX XXX *
>
> 6 ign ADAM XXX XXX OH
> 7 leg ADAM XXX XXX *
>
> 8 ign ADAR XXX XXX OH
> 9 leg ADAR XXX XXX *
>
> 10 ign AHSK XXX XXX NC
> 11 leg AHSK XXX XXX *
>
> 12 ign ALDN XXX XXX KS
> 13 leg ALDN XXX XXX *
>
> The code below is highlighting cells e1 and e2, e3 and e4, which is correct
> because columns A and B meet the criteria.
>
> And cell e5 is not highlighted, which is also correct because it does not
> meet the criteria.
>
> However, the highlight is not being picked up at cells e6 and e7, e8 and e9,
> e10 and e11, and e12 and e13, which it should because Column A and B fit the
> criteria for these matches, ign and leg and identical id code.
>
> Can you please, pleasssssse help me with this code. Thank you in advance.
>
> phmckeever
>
>
> Range("A1").Select
> Set Record1 = Range("$b2")
> Set Record2 = Range("$b3")
> Range("A1").Select
>
> Do While (Record1 <> "")
> If (Record1 = Record2) Then
> IngRow = Record1.Row
>
> strRow1 = Trim$(Str$(IngRow))
> strRow2 = Trim$(Str$(IngRow + 1))
>
> s = "=AND($A" & strRow1 & "=""ign"", " & _
> "$A" & strRow2 & "=""leg""," & _
> "$B" & strRow1 & "=$B" & strRow2 & ")"
>
> if evaluate(s) = true then
> Set rngAll = Range("$C" & strRow1 & ":$E" & strRow2)
> rngAll.FormatConditions.Delete
>
> For x = 1 To rngAll.Columns.Count
>
> strFormula = "=AND($A" & strRow1 & "=""ign"", " & _
> "$A" & strRow2 & "=""leg""," & _
> "$B" & strRow1 & "=$B" & strRow2 & "," & _
> rngAll.Cells(1, x).Address & "<>" & _
> rngAll.Cells(2, x).Address & ")"
>
> rngAll.Cells(1, x).Select
> Selection.FormatConditions.Add _
> Type:=xlExpression, Formula1:=strFormula
> Selection.FormatConditions(1).Interior.ColorIndex = 6
>
> rngAll.Cells(2, x).Select
> Selection.FormatConditions.Add _
> Type:=xlExpression, Formula1:=strFormula
> Selection.FormatConditions(1).Interior.ColorIndex = 6
>
> Next x
>
> End if
>
> End If
>
> Set Record1 = Record1.Offset(2, 0)
> Set Record2 = Record2.Offset(2, 0)
>
> Loop

 
Reply With Quote
 
acampbell012@yahoo.com
Guest
Posts: n/a
 
      31st Oct 2006
Regarding your requirement ...and have identical ID codes in column
B... Do you mean Rows 1 and 2, 3 and 4, etc. have to match in column B
to complete the highlighting?


phmckeever wrote:
> The first sentence after hello should read,
>
> I need the data in column "E", not C.
>
> "phmckeever" wrote:
>
> >
> > Hello,
> > I need the data in column C to be highlighted when rows begin with 'ign' and
> > 'leg' in column A and have identical ID codes in column B.
> >
> > Here is a 'cut and paste' from the worksheet (The XXX is just placeholders
> > to demonstrate; and the spacing between the rows is for clarity).
> >
> > A B C D E
> > 1 ign ABGN XXX XXX VA
> > 2 leg ABGN XXX XXX *
> >
> > 3 ign ABVL XXX XXX KS
> > 4 leg ABVL XXX XXX *
> >
> > 5 leg ADA XXX XXX *
> >
> > 6 ign ADAM XXX XXX OH
> > 7 leg ADAM XXX XXX *
> >
> > 8 ign ADAR XXX XXX OH
> > 9 leg ADAR XXX XXX *
> >
> > 10 ign AHSK XXX XXX NC
> > 11 leg AHSK XXX XXX *
> >
> > 12 ign ALDN XXX XXX KS
> > 13 leg ALDN XXX XXX *
> >
> > The code below is highlighting cells e1 and e2, e3 and e4, which is correct
> > because columns A and B meet the criteria.
> >
> > And cell e5 is not highlighted, which is also correct because it does not
> > meet the criteria.
> >
> > However, the highlight is not being picked up at cells e6 and e7, e8 and e9,
> > e10 and e11, and e12 and e13, which it should because Column A and B fit the
> > criteria for these matches, ign and leg and identical id code.
> >
> > Can you please, pleasssssse help me with this code. Thank you in advance.
> >
> > phmckeever
> >
> >
> > Range("A1").Select
> > Set Record1 = Range("$b2")
> > Set Record2 = Range("$b3")
> > Range("A1").Select
> >
> > Do While (Record1 <> "")
> > If (Record1 = Record2) Then
> > IngRow = Record1.Row
> >
> > strRow1 = Trim$(Str$(IngRow))
> > strRow2 = Trim$(Str$(IngRow + 1))
> >
> > s = "=AND($A" & strRow1 & "=""ign"", " & _
> > "$A" & strRow2 & "=""leg""," & _
> > "$B" & strRow1 & "=$B" & strRow2 & ")"
> >
> > if evaluate(s) = true then
> > Set rngAll = Range("$C" & strRow1 & ":$E" & strRow2)
> > rngAll.FormatConditions.Delete
> >
> > For x = 1 To rngAll.Columns.Count
> >
> > strFormula = "=AND($A" & strRow1 & "=""ign"", " & _
> > "$A" & strRow2 & "=""leg""," & _
> > "$B" & strRow1 & "=$B" & strRow2 & "," & _
> > rngAll.Cells(1, x).Address & "<>" & _
> > rngAll.Cells(2, x).Address & ")"
> >
> > rngAll.Cells(1, x).Select
> > Selection.FormatConditions.Add _
> > Type:=xlExpression, Formula1:=strFormula
> > Selection.FormatConditions(1).Interior.ColorIndex = 6
> >
> > rngAll.Cells(2, x).Select
> > Selection.FormatConditions.Add _
> > Type:=xlExpression, Formula1:=strFormula
> > Selection.FormatConditions(1).Interior.ColorIndex = 6
> >
> > Next x
> >
> > End if
> >
> > End If
> >
> > Set Record1 = Record1.Offset(2, 0)
> > Set Record2 = Record2.Offset(2, 0)
> >
> > Loop


 
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
Highlighting a cell jlojones821 Microsoft Excel Misc 6 14th Jul 2008 06:53 PM
cell highlighting =?Utf-8?B?YmNzdW5pZmk=?= Microsoft Excel Crashes 2 26th Sep 2007 05:46 AM
highlighting cell owl527 Microsoft Excel Programming 4 28th Nov 2005 03:20 PM
Highlighting A Cell Coltsfan Microsoft Excel Misc 1 19th Sep 2005 10:24 PM
Highlighting a cell Vlad Microsoft Excel Programming 3 26th May 2004 03:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:13 PM.