View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Victor H[_2_] Victor H[_2_] is offline
external usenet poster
 
Posts: 1
Default Selecting consecutive rows in VBA

Thanks Chris.


-----Original Message-----
'This codes assumes your dates are sorted.
'When it finds The first matching date it will do a

copy for each subsequent row Until It does not find a
matching date.

For Each c In ActiveSheet.UsedRange.Range("A:A") '<< The

Column with the Date
If FoundDate = True And C<Today()-1 Then Exit Sub
If IsDate(C) And C = Today()-1 Then
FoundDate = True
C.EntireRow.Copy Destination:= Sheets

("CopySheet").Rows( Sheets
("CopySheet").UsedRange.Rows.Count +1)
End If
Next C
----- Victor H wrote: -----

I have a worksheet with rows covering 14 columns

from (Axx
to Nxx).
The first row contains a date. The other rows

contain
miscellaneous other data.

Out of all the rows already in the worksheet, I need

to
select those rows (they are consecutive) that

satisfy the
following criteria:

Select row if Axx = Today()-1 (Axx is already

formatted as
a Date)

In other words, I'd like to select all rows with
yesterday's date and paste them to another worksheet.

I've already written a macro that does that, but I

have to
select the rows myself before the macro copies and

pastes.
That macro would look a lot better if it could work
unattended.

Thanks in advance for any help.

.