Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copy and pasting ranges

I am new to programming in Excel, so forgive me if there is an obvious answer
to this question.

I have created a button that will copy 2 ranges from 2 different
spreadsheets and paste them onto a 3rd spreadsheet. The button is located on
the 3rd spreadsheet. The code copies and pastes the 1st range, then moves
the curser to a new line, then copies and pastes the 2nd range.

The code works fine for the 1st range and repositioning the curser, but when
it gets to the 2nd range, it give me an error.
"Run-time error €˜1004:
The information cannot be pasted because the Copy area and the paste area
are not the same size and shape."

Then it brings me to the ActiveSheet.Paste line in the 2nd Paste code. (See
full code below.)

Worksheets("Danka").Range("DANKA").Copy
†’†’ ActiveSheet.Paste

If I take out the code for the 2nd range the code works fine with no errors
and the curser is left on a new line.

Here's the code I'm using:

Private Sub Ranges_Click()

Worksheets("Charrette").Range("CHARRETTE").Copy
ActiveSheet.Paste

Application.SendKeys ("{ESCAPE}")
Application.SendKeys ("{DOWN}")
Application.SendKeys ("{END}")
Application.SendKeys ("{DOWN}")
Application.SendKeys ("{DOWN}")

Worksheets("Danka").Range("DANKA").Copy
ActiveSheet.Paste

End Sub

Can someone please help me?

Thank you,

Rachel

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Copy and pasting ranges

Not Sure what you are trying to do with the send key methods, but try
this code out in a copy of you workbook and see if it does what you
want it to do. This will find the last row in Column A in your
activesheet then move down 1 row and paste your first range, then move
down one more and paste the second range.

Private Sub Ranges_Click()
Dim aSheet As Worksheet
Set aSheet = ActiveSheet
aSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
Worksheets("Charrette").Range("CHARRETTE").Copy
aSheet.Paste

aSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
Worksheets("Danka").Range("DANKA").Copy
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub


hope this is what you were looking for

Sandy
RFrechette wrote:
I am new to programming in Excel, so forgive me if there is an obvious answer
to this question.

I have created a button that will copy 2 ranges from 2 different
spreadsheets and paste them onto a 3rd spreadsheet. The button is located on
the 3rd spreadsheet. The code copies and pastes the 1st range, then moves
the curser to a new line, then copies and pastes the 2nd range.

The code works fine for the 1st range and repositioning the curser, but when
it gets to the 2nd range, it give me an error.
"Run-time error €˜1004:
The information cannot be pasted because the Copy area and the paste area
are not the same size and shape."

Then it brings me to the ActiveSheet.Paste line in the 2nd Paste code. (See
full code below.)

Worksheets("Danka").Range("DANKA").Copy
†’†’ ActiveSheet.Paste

If I take out the code for the 2nd range the code works fine with no errors
and the curser is left on a new line.

Here's the code I'm using:

Private Sub Ranges_Click()

Worksheets("Charrette").Range("CHARRETTE").Copy
ActiveSheet.Paste

Application.SendKeys ("{ESCAPE}")
Application.SendKeys ("{DOWN}")
Application.SendKeys ("{END}")
Application.SendKeys ("{DOWN}")
Application.SendKeys ("{DOWN}")

Worksheets("Danka").Range("DANKA").Copy
ActiveSheet.Paste

End Sub

Can someone please help me?

Thank you,

Rachel


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copy and pasting ranges

Thank you, thank you, thank you!

It worked perfectly. You're an angel.

Rachel

"Sandy" wrote:

Not Sure what you are trying to do with the send key methods, but try
this code out in a copy of you workbook and see if it does what you
want it to do. This will find the last row in Column A in your
activesheet then move down 1 row and paste your first range, then move
down one more and paste the second range.

Private Sub Ranges_Click()
Dim aSheet As Worksheet
Set aSheet = ActiveSheet
aSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
Worksheets("Charrette").Range("CHARRETTE").Copy
aSheet.Paste

aSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
Worksheets("Danka").Range("DANKA").Copy
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub


hope this is what you were looking for

Sandy
RFrechette wrote:
I am new to programming in Excel, so forgive me if there is an obvious answer
to this question.

I have created a button that will copy 2 ranges from 2 different
spreadsheets and paste them onto a 3rd spreadsheet. The button is located on
the 3rd spreadsheet. The code copies and pastes the 1st range, then moves
the curser to a new line, then copies and pastes the 2nd range.

The code works fine for the 1st range and repositioning the curser, but when
it gets to the 2nd range, it give me an error.
"Run-time error €˜1004:
The information cannot be pasted because the Copy area and the paste area
are not the same size and shape."

Then it brings me to the ActiveSheet.Paste line in the 2nd Paste code. (See
full code below.)

Worksheets("Danka").Range("DANKA").Copy
†’†’ ActiveSheet.Paste

If I take out the code for the 2nd range the code works fine with no errors
and the curser is left on a new line.

Here's the code I'm using:

Private Sub Ranges_Click()

Worksheets("Charrette").Range("CHARRETTE").Copy
ActiveSheet.Paste

Application.SendKeys ("{ESCAPE}")
Application.SendKeys ("{DOWN}")
Application.SendKeys ("{END}")
Application.SendKeys ("{DOWN}")
Application.SendKeys ("{DOWN}")

Worksheets("Danka").Range("DANKA").Copy
ActiveSheet.Paste

End Sub

Can someone please help me?

Thank you,

Rachel



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Copy and pasting ranges

Happy to help!

Sandy


RFrechette wrote:
Thank you, thank you, thank you!

It worked perfectly. You're an angel.

Rachel

"Sandy" wrote:

Not Sure what you are trying to do with the send key methods, but try
this code out in a copy of you workbook and see if it does what you
want it to do. This will find the last row in Column A in your
activesheet then move down 1 row and paste your first range, then move
down one more and paste the second range.

Private Sub Ranges_Click()
Dim aSheet As Worksheet
Set aSheet = ActiveSheet
aSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
Worksheets("Charrette").Range("CHARRETTE").Copy
aSheet.Paste

aSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
Worksheets("Danka").Range("DANKA").Copy
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub


hope this is what you were looking for

Sandy
RFrechette wrote:
I am new to programming in Excel, so forgive me if there is an obvious answer
to this question.

I have created a button that will copy 2 ranges from 2 different
spreadsheets and paste them onto a 3rd spreadsheet. The button is located on
the 3rd spreadsheet. The code copies and pastes the 1st range, then moves
the curser to a new line, then copies and pastes the 2nd range.

The code works fine for the 1st range and repositioning the curser, but when
it gets to the 2nd range, it give me an error.
"Run-time error €˜1004:
The information cannot be pasted because the Copy area and the paste area
are not the same size and shape."

Then it brings me to the ActiveSheet.Paste line in the 2nd Paste code.. (See
full code below.)

Worksheets("Danka").Range("DANKA").Copy
†’†’ ActiveSheet.Paste

If I take out the code for the 2nd range the code works fine with no errors
and the curser is left on a new line.

Here's the code I'm using:

Private Sub Ranges_Click()

Worksheets("Charrette").Range("CHARRETTE").Copy
ActiveSheet.Paste

Application.SendKeys ("{ESCAPE}")
Application.SendKeys ("{DOWN}")
Application.SendKeys ("{END}")
Application.SendKeys ("{DOWN}")
Application.SendKeys ("{DOWN}")

Worksheets("Danka").Range("DANKA").Copy
ActiveSheet.Paste

End Sub

Can someone please help me?

Thank you,

Rachel




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
Pasting Large Ranges into a List Jamesh5q6 Excel Worksheet Functions 2 August 13th 07 01:28 PM
Copy data in named ranges to a newer version of the same template to identical ranges handstand Excel Programming 0 August 21st 06 03:51 PM
cutting and pasting ranges using offsets timmulla Excel Programming 2 July 14th 05 06:28 PM
how to avoid merging when pasting multiple ranges Stian Excel Programming 6 May 20th 05 03:29 PM
Selecting & Pasting Dynamic Ranges GerryM[_2_] Excel Programming 4 November 17th 04 09:12 AM


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