Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Macro to highlight rows and...

I'm Baaaack <g! I hacked on this li'l dude for a couple of hours yesterday,
and it still won't behave. Here it is as far as i have gone with it:

Sub TryNow()
Dim myCount As Integer
Dim StartRow As Long
Dim myCell As Range
myCount = 0
For Each myCell In Range("C2:C53")
StartRow = myCell.Row
If myCell.Value < myCell(2, 1).Value Then
If myCell(2, 9).Value < "PEN-Pensionable Earnings" Then
myCount = 1
While myCell(myCount + 1, 1).Value = myCell(myCount + 2, 1)
myCount = myCount + 1
Wend
StartRow = StartRow + myCount - 3
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(("A" & StartRow), ("Q" & StartRow + myCount - 1)).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
myCount = 0
Else
myCount = 0
End If
Else
myCount = myCount + 1
End If
Next myCell
End Sub

Column C contains SSNs, on which the data is sorted. Column K (myCell(2,9)
contains a variety of terms which identify the type of numeric data. One of
the terms associated with most of the people is "PEN-Pensionable Earnings".
If a person does NOT have that in the first row, then he/she does not have it
at all.

I need to highlight all the rows of those folks without the Pensionable
Earnings and change the background color. It seems to work with certain
numbers of rows after the first, and then grab the wrong row as the first row
with a different number of rows. Individuals could have anywhere from two to
ten rows total each, hence the counter.

Once I have done all that, I will return to the data with a second macro
that will find all the folks WITH the Pensionable Earnings item, add up all
the rows following that item (from Column J) and compare the total of those
to the value in Column J on the Pensionable Earnings row. If they do not
match I will highlight those rows in a different background color, as well as
printing out the total in column AA.

Dang, it sounds complex, but it shouldn't be as difficult as I am finding
it. I would have no problem writing something to do this if I were working in
VFP -- but I'm not, am I? <g!

Anyone feel like jumping in and taking a whack at this?
--
Dave
Temping with Staffmark
in Rock Hill, SC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Macro to highlight rows and...

Hacked away some this morning and got the row coloring macro working. I think
I can get the second one fairly easily by hacking the first one.
--
Dave
Temping with Staffmark
in Rock Hill, SC


"Dave Birley" wrote:

I'm Baaaack <g! I hacked on this li'l dude for a couple of hours yesterday,
and it still won't behave. Here it is as far as i have gone with it:

Sub TryNow()
Dim myCount As Integer
Dim StartRow As Long
Dim myCell As Range
myCount = 0
For Each myCell In Range("C2:C53")
StartRow = myCell.Row
If myCell.Value < myCell(2, 1).Value Then
If myCell(2, 9).Value < "PEN-Pensionable Earnings" Then
myCount = 1
While myCell(myCount + 1, 1).Value = myCell(myCount + 2, 1)
myCount = myCount + 1
Wend
StartRow = StartRow + myCount - 3
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(("A" & StartRow), ("Q" & StartRow + myCount - 1)).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
myCount = 0
Else
myCount = 0
End If
Else
myCount = myCount + 1
End If
Next myCell
End Sub

Column C contains SSNs, on which the data is sorted. Column K (myCell(2,9)
contains a variety of terms which identify the type of numeric data. One of
the terms associated with most of the people is "PEN-Pensionable Earnings".
If a person does NOT have that in the first row, then he/she does not have it
at all.

I need to highlight all the rows of those folks without the Pensionable
Earnings and change the background color. It seems to work with certain
numbers of rows after the first, and then grab the wrong row as the first row
with a different number of rows. Individuals could have anywhere from two to
ten rows total each, hence the counter.

Once I have done all that, I will return to the data with a second macro
that will find all the folks WITH the Pensionable Earnings item, add up all
the rows following that item (from Column J) and compare the total of those
to the value in Column J on the Pensionable Earnings row. If they do not
match I will highlight those rows in a different background color, as well as
printing out the total in column AA.

Dang, it sounds complex, but it shouldn't be as difficult as I am finding
it. I would have no problem writing something to do this if I were working in
VFP -- but I'm not, am I? <g!

Anyone feel like jumping in and taking a whack at this?
--
Dave
Temping with Staffmark
in Rock Hill, SC

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
more rows highlight than I want ren Excel Discussion (Misc queries) 1 March 14th 10 10:02 AM
Highlight rows Scott R Excel Worksheet Functions 5 December 5th 07 01:19 AM
Can I highlight all the odd rows in Excel? paulkc Excel Discussion (Misc queries) 1 November 21st 05 01:46 PM
Highlight rows Randy Reese Excel Programming 4 March 4th 04 09:36 PM
Highlight non- contiguous rows Steve[_54_] Excel Programming 5 December 23rd 03 11:10 PM


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