Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Coping ranges of cells

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Coping ranges of cells

When you talk about efficientcy I assume you would mean NOT using the clip
board. Doing a COPY and then a PASTE uses the clip board. I prefer using
the COPY weith the destination in the same statement


range("A3:B7").copy destination:=sheets("Sheet2").range("D5")

"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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Coping ranges of cells

Your saying Column 3 has hours worked and the day they worked??

"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


  #4   Report Post  
Posted to microsoft.public.excel.programming
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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Coping ranges of cells

On Jul 1, 7:12 pm, Mike wrote:
Your saying Column 3 has hours worked and the day they worked??


Mike,

I wasn't very clear, sorry. Assume a header row with labels: Employee,
Project, Jan1, Jan2, Jan3, ...
Now starting from row 2 you have data like John Doe, ProjectX, 2, 3, 7
2, ....
This particular record (row) would mean that John Doe worked on
ProjectX for 2 hours on Jan 1, for 3 hours on Jan 2, for 7 hours on
Jan 3, ...

Joel,

You suggested range("A3:B7").copy ...Thanks, but if I know I want to
copy rows 3-7 columns A, B, G and H, say, it would be more convenient
to you R1C1 format for the range, but I haven't been able to figure
out how to do that with the range.copy method. Help please.

Tom Ogilvy,

Wow. You were way over my head with your code -- I've got a lot to
learn. I tried looking up Application.Match but it Match was not
listed as a method of the Application object, nor could I find
anything on clng. Little more help please.

David


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
Coping info inside cells Hinojosa Excel Programming 6 November 22nd 06 11:54 PM
coping cells JJMNZ76 Excel Programming 4 October 5th 06 09:22 PM
Macro for coping cells from one worksheet to another ShahAFFS Excel Programming 3 August 31st 05 11:28 AM
Trouble Coping Visible Cells JenYancey Excel Discussion (Misc queries) 2 May 25th 05 12:17 AM
Coping all cells with data. Pete Excel Programming 0 January 8th 04 09:40 PM


All times are GMT +1. The time now is 11:31 AM.

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"