Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Need macro to move cell contents from one sheet to another

I need a macro to move the contents of 5 columns (A-E) on one sheet to the
bottom of a set of data on another page. Variables to deal with:
1) There will be a variable amount of rows on the first sheet,
2) the end of the data set on the second page will move down each time new
data is added,
3) There are sum() formulas at the bottom of the second page in columns
(A-H) to total the data above - note there are more columns on second page.
I need the contents of the first page to be added above the "total" row and
have the sum() formulas move down accordingly in columns (A-H).
- Note: I have an empty row between the data on page 2 and the sum() row.

I keep getting an error message that says the paste area has to be the same
size as the copy area.

Any thoughts?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need macro to move cell contents from one sheet to another

Use code like the following. Change the lines marked with <<< to the
appropriate values.


Sub CopyData()
Dim SourceFirstRow As Long
Dim SourceLastRow As Long
Dim DestLastRow As Long
Dim SourceWS As Worksheet
Dim DestWS As Worksheet
Dim CopyRange As Range

SourceFirstRow = 1 '<<< CHANGE AS NEEDED
Set SourceWS = Worksheets("Sheet1") '<<< CHANGE AS NEEDED
Set DestWS = Worksheets("Sheet2") '<<< CHANGE AS NEEDED
With SourceWS
SourceLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set CopyRange = .Range(.Cells(SourceFirstRow, "A"), _
.Cells(SourceLastRow, "H"))
End With
With DestWS
DestLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Rows(DestLastRow).Resize(CopyRange.Rows.Count).In sert
CopyRange.Copy Destination:=.Cells(DestLastRow, "A")
End With
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Sun, 8 Mar 2009 08:10:01 -0700, Bern Notice
wrote:

I need a macro to move the contents of 5 columns (A-E) on one sheet to the
bottom of a set of data on another page. Variables to deal with:
1) There will be a variable amount of rows on the first sheet,
2) the end of the data set on the second page will move down each time new
data is added,
3) There are sum() formulas at the bottom of the second page in columns
(A-H) to total the data above - note there are more columns on second page.
I need the contents of the first page to be added above the "total" row and
have the sum() formulas move down accordingly in columns (A-H).
- Note: I have an empty row between the data on page 2 and the sum() row.

I keep getting an error message that says the paste area has to be the same
size as the copy area.

Any thoughts?

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
Move cell contents with macro Peridot Excel Discussion (Misc queries) 4 September 30th 09 03:35 PM
macro to move cell contents and then delete the row Mark64 Excel Programming 1 October 13th 06 02:50 PM
macro to move cell contents and then delete the row Mark64 Excel Programming 3 October 12th 06 09:29 PM
Macro to move the contents of a cell JenBasch Excel Programming 1 September 20th 05 01:47 AM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM


All times are GMT +1. The time now is 11:21 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"