![]() |
Help needed with copying from one worksheet to another
Hi,
I am trying to write a macro to help me sort out some data for some reports I am running,( I have not really used macro's before and so don't really know where to start. Below is a small example of what I am starting with, This covers a period from 01/04/06 - 31/03/07 I have sorted the date column in order and currently I am using a customised date format to display just the month. Name of the business event Event Type Start date Fee ICT May 0.00 ICT May 55.00 Equality and Diversity May 75.00 Dealing With Customers May 75.00 I have the workbook set up to have 13 worksheets - the first on named Full year is where the data is being pulled from, I then have each of the others named April ...........March. And they all Have the same headings in Row 1 What I am trying to do is to copy the data from the 1st sheet into the correct monthly named sheet, - IE if the date says may then I want the whole row copying into the first empty row in the worksheet"May" If anybody can help I would appreciate it, If you need any more information from me please let me know. Thanks in Advance. |
Help needed with copying from one worksheet to another
This assumes your dates are in column C of the first sheet in the tab order.
Sub copyData() Dim rng as Range, cell as Range Dim cell1 as Range, sh as Worksheet with worksheets(1) set rng = .Range(.Cells(2,3),.Cells(rows.count,3).End(xlup)) End with rng.Interior.ColorIndex = xlNone for each cell in rng set sh = Nothing on error resume Next set sh = worksheets(cell.Text) On error goto 0 if not sh is nothing then set cell1 = sh.Cells(rows.count,3).End(xlup)(2) cell.EntireRow.copy cell1.EntireRow else cell.Interior.ColorIndex = 3 end if Next End sub In the vbe, do Insert=Module Place the code in that module. -- Regards, Tom Ogilvy "Ricco" wrote: Hi, I am trying to write a macro to help me sort out some data for some reports I am running,( I have not really used macro's before and so don't really know where to start. Below is a small example of what I am starting with, This covers a period from 01/04/06 - 31/03/07 I have sorted the date column in order and currently I am using a customised date format to display just the month. Name of the business event Event Type Start date Fee ICT May 0.00 ICT May 55.00 Equality and Diversity May 75.00 Dealing With Customers May 75.00 I have the workbook set up to have 13 worksheets - the first on named Full year is where the data is being pulled from, I then have each of the others named April ...........March. And they all Have the same headings in Row 1 What I am trying to do is to copy the data from the 1st sheet into the correct monthly named sheet, - IE if the date says may then I want the whole row copying into the first empty row in the worksheet"May" If anybody can help I would appreciate it, If you need any more information from me please let me know. Thanks in Advance. |
Help needed with copying from one worksheet to another
Hi,
Thanks for your help, Joel I tried your code but kept getting a error message, Tom yours does the job great. Thanks. again. |
All times are GMT +1. The time now is 11:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com