Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Selecting a Range based on an IF condition

Here's what I've hacked together that doesn't work:

Sub TryNow()
Dim myCount As Integer
Dim StartRow As Integer
Dim myCell As Range
myCount = 0
For Each myCell In Range("C2", Range("C30").End(xlUp))
StartRow = myCell.Row
If myCell.Value < myCell(2, 1).Value Then
StartRow = StartRow - myCount
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(("A" & StartRow), ("Q" & StartRow + myCount)).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
myCount = 0
Else
myCount = myCount + 1
End If
Next myCell
End Sub

I plan to hack into it when this much gets working and add a condition of

"If the First cell in column K of this set does not contain 'Yadda-Yadda'"
to be the limiting component of the sets.

The objective here is to find the rows of data for individuals who don't
have the qualifying text in the First row, Column K, and then select all the
rows for that individual and highlight them.

A little help is needed once more -- all contributions gratefully received.
--
Dave
Temping with Staffmark
in Rock Hill, SC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Selecting a Range based on an IF condition

Dave,

It will be easy to do once you explain it a little better. I have no idea what you mean by:

"The objective here is to find the rows of data for individuals who don't
have the qualifying text in the First row, Column K, and then select all the
rows for that individual and highlight them."

Perhaps an example would be appropriate...


HTH,
Bernie
MS Excel MVP


"Dave Birley" wrote in message
...
Here's what I've hacked together that doesn't work:

Sub TryNow()
Dim myCount As Integer
Dim StartRow As Integer
Dim myCell As Range
myCount = 0
For Each myCell In Range("C2", Range("C30").End(xlUp))
StartRow = myCell.Row
If myCell.Value < myCell(2, 1).Value Then
StartRow = StartRow - myCount
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(("A" & StartRow), ("Q" & StartRow + myCount)).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
myCount = 0
Else
myCount = myCount + 1
End If
Next myCell
End Sub

I plan to hack into it when this much gets working and add a condition of

"If the First cell in column K of this set does not contain 'Yadda-Yadda'"
to be the limiting component of the sets.

The objective here is to find the rows of data for individuals who don't
have the qualifying text in the First row, Column K, and then select all the
rows for that individual and highlight them.

A little help is needed once more -- all contributions gratefully received.
--
Dave
Temping with Staffmark
in Rock Hill, SC



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Selecting a Range based on an IF condition

Help us to understand what you want to do.

"Dave Birley" wrote:

Here's what I've hacked together that doesn't work:

Sub TryNow()
Dim myCount As Integer
Dim StartRow As Integer
Dim myCell As Range
myCount = 0
For Each myCell In Range("C2", Range("C30").End(xlUp))
StartRow = myCell.Row
If myCell.Value < myCell(2, 1).Value Then
StartRow = StartRow - myCount
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(("A" & StartRow), ("Q" & StartRow + myCount)).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
myCount = 0
Else
myCount = myCount + 1
End If
Next myCell
End Sub

I plan to hack into it when this much gets working and add a condition of

"If the First cell in column K of this set does not contain 'Yadda-Yadda'"
to be the limiting component of the sets.

The objective here is to find the rows of data for individuals who don't
have the qualifying text in the First row, Column K, and then select all the
rows for that individual and highlight them.

A little help is needed once more -- all contributions gratefully received.
--
Dave
Temping with Staffmark
in Rock Hill, SC

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Selecting a Range based on an IF condition

Sorry, folks, it was the .Row thing I was having trouble with, and once I
learned that I was using it correctly, I was able to step through the Macro
and see what's going on. I think I'm onto its taail now, so thanks for being
there, and wanting to help, and sorry for wasting your time on this one.

Worry not, I shall return <g!
--
Dave
Temping with Staffmark
in Rock Hill, SC


"Barb Reinhardt" wrote:

Help us to understand what you want to do.

"Dave Birley" wrote:

Here's what I've hacked together that doesn't work:

Sub TryNow()
Dim myCount As Integer
Dim StartRow As Integer
Dim myCell As Range
myCount = 0
For Each myCell In Range("C2", Range("C30").End(xlUp))
StartRow = myCell.Row
If myCell.Value < myCell(2, 1).Value Then
StartRow = StartRow - myCount
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(("A" & StartRow), ("Q" & StartRow + myCount)).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
myCount = 0
Else
myCount = myCount + 1
End If
Next myCell
End Sub

I plan to hack into it when this much gets working and add a condition of

"If the First cell in column K of this set does not contain 'Yadda-Yadda'"
to be the limiting component of the sets.

The objective here is to find the rows of data for individuals who don't
have the qualifying text in the First row, Column K, and then select all the
rows for that individual and highlight them.

A little help is needed once more -- all contributions gratefully received.
--
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
Condition based copy/paste of range [email protected] Excel Programming 1 April 28th 07 11:30 PM
Condition based copy/paste of range [email protected] Excel Programming 1 April 27th 07 12:44 PM
Condition based copy/paste of range [email protected] Excel Programming 0 April 27th 07 05:48 AM
Copy range based on condition Sotomayor Excel Programming 1 September 10th 06 01:11 AM
How to copy only some rows from range based on condition? [email protected][_2_] Excel Programming 2 January 30th 06 01:04 AM


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