View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Coping ranges of cells

Something along the lines of

Dim rng as Range, rng1 as range
Dim rng2 as Range
With Worksheets("Sheet1")
set rng = .Range(.cells(2,3),.Cells(rows.count,3).End(xlup))


res = Application.Match(clng(DateValue("Jan 8, 2007")),rng,0)
if not iserror(res) then
set rng1 = rng(res)
res = Application.Match(clng(DateValue("Mar 2, 2007")),rng,0)
if not iserror(res) then
set rng2 = rng(res)
.Range(rng1,rng2).Offset(0,-2).Resize(,4).copy
Worksheets("Sheet2").Range("A2")
end if
End if

End With

--
Regards,
Tom Ogilvy

"David" wrote:

I have a worksheet which has hours worked by employees on various
projects over the last year. So, column 1 is the employee name, column
2 is the project name and column 3 starts with Jan 1 and continues on,
so the number in column 3 represents the hours that the employee
(named in column 1) worked on the project (named in column 2) on Jan
1, and column 3 is the hours worked on Jan 2, etc.

I have to write a routine that copies all the data for a given
employee for dates between some start date and some end date to a new
worksheet in the same workbook. This new worksheet will have column 1
being employee name, column 2 being project, column 3 being the hours
worked on the start date, etc.

What is the most efficient way to copy ranges of rows and columns to
the new worksheet?

Thanks,

David