View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_4_] Alan Beban[_4_] is offline
external usenet poster
 
Posts: 171
Default Selecting Rows by Column Value

What I meant by the question was: more immediately, what is the next
command after selecting the relevant rows? The point of the question was
to raise the issue of whether you relly wanted to select the appropriate
rows, or rather just do something with them.

But be that as it may, something like the following will identify the
starting and ending rows for each value:

Sub test1000()
Dim rng as Range
Dim startRow1 As Long, endRow1 As Long
Dim startRow2 As Long, endRow2 As Long
Set rng = Sheets(4).Range("D:D")
startRow1 = rng.Find("VALUE1", rng(65536)).Row
endRow1 = rng.Find("VALUE1", rng(65536), , , , xlPrevious).Row
startRow2 = rng.Find("VALUE2", rng(65536)).Row
endRow2 = rng.Find("VALUE2", rng(65536), , , , xlPrevious).Row
Debug.Print startRow1; endRow1; startRow2; endRow2
End Sub

Alan Beban

Ed wrote:
The selceted rows will be made to into a .csv file.



"Alan Beban" wrote in message
...

What is supposed to happen after the rows are selected?

Alan Beban

Ed wrote:

My column "D" has only two values in it, (VALUE1 and VALUE2). My sheet


is

sorted by this column. What I want need my macro to do is only select


the

rows that have VALUE1 in column "D". Each time I run this the file size
would be different, so the first time my selection might be rows 1


through

1855. The next time it might be rows 1200 through 3500. The selection


will

always be grouped together because of the sort.


T.I.A.
Ed