Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how would i select a group of rows based on a column value

This question has to be one of the most frequently asked question and
I am sorry I have to ask it agin.. but I have been unable to find an
acceptable solution.

What I am currently doing is sorting a sheet by a particualr column.
Then manually selecting all the rows from top to bottom that have the
same value in a particular column... After that I trigger my macro and
it does it's thing. (cuts and pastes in a new sheet)

What I'd like for my macro to do.... Select the rows by it's self.

What I'd like the macro to do is..

if D2 = D1 add row 2 to the selection
if D3 = D1 add row 3 to the selection
if D4 = D1 add row 4 to the selection
untill D? does not = D1 then break the loop and continue on with the
rest of the macro...

here is what I am doing now..

Sub weeklyreport()

' some one please help me put a line of code or a sub that will select
my data
Selection.Cut
Sheets.Add

Call paste ' a non relevant sub routine
Call pageset ' a non relevant sub routine
Call adddata ' a non relevant sub routine
Call mailme ' a non relevant sub routine
Call shift ' a non relevant sub routine

End Sub



Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default how would i select a group of rows based on a column value

Brian,

Try this:

Dim TestRow As Long, SelectRow As Long
TestRow = 2 ' starting row
SelectRow = 1 ' bottom row extent to select
Do While Cells(TestRow, 4) < ""
If Cells(TestRow, 4) = Range("D1") Then
SelectRow = TestRow
TestRow = TestRow + 1

Else
Exit Do
End If
Loop
Range(Cells(1, 1), Cells(SelectRow, 1)).EntireRow.Select

' Optional: Is next cell out of sequence?
If Cells(SelectRow, 4) Cells(SelectRow + 1, 4) _
And Cells(SelectRow + 1, 4) < "" Then
MsgBox "Column D has a sequence error", , "Aaaahhh!"
End If

--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Brian Walker" wrote in message
m...
This question has to be one of the most frequently asked question and
I am sorry I have to ask it agin.. but I have been unable to find an
acceptable solution.

What I am currently doing is sorting a sheet by a particualr column.
Then manually selecting all the rows from top to bottom that have the
same value in a particular column... After that I trigger my macro and
it does it's thing. (cuts and pastes in a new sheet)

What I'd like for my macro to do.... Select the rows by it's self.

What I'd like the macro to do is..

if D2 = D1 add row 2 to the selection
if D3 = D1 add row 3 to the selection
if D4 = D1 add row 4 to the selection
untill D? does not = D1 then break the loop and continue on with the
rest of the macro...

here is what I am doing now..

Sub weeklyreport()

' some one please help me put a line of code or a sub that will select
my data
Selection.Cut
Sheets.Add

Call paste ' a non relevant sub routine
Call pageset ' a non relevant sub routine
Call adddata ' a non relevant sub routine
Call mailme ' a non relevant sub routine
Call shift ' a non relevant sub routine

End Sub



Any ideas?



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
Help tonight?!! select rows based on cell value in a column Lighthouse1 Excel Worksheet Functions 1 January 31st 07 03:57 AM
Need to select rows to average based on a value in a different column Randy K New Users to Excel 1 February 15th 06 02:03 AM
format group of rows based on condition Aaron Excel Discussion (Misc queries) 0 January 10th 06 01:29 AM
Select rows based on criteria sotiris_s Excel Worksheet Functions 4 November 14th 05 01:35 PM
Is there a smart way to select multiple rows based on column... Mike[_81_] Excel Programming 6 May 1st 04 12:51 PM


All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"