PC Review


Reply
Thread Tools Rate Thread

Copy and pasting ranges

 
 
=?Utf-8?B?UkZyZWNoZXR0ZQ==?=
Guest
Posts: n/a
 
      20th Nov 2006
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 With Quote
 
 
 
 
Sandy
Guest
Posts: n/a
 
      20th Nov 2006
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 With Quote
 
=?Utf-8?B?UkZyZWNoZXR0ZQ==?=
Guest
Posts: n/a
 
      20th Nov 2006
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 With Quote
 
Sandy
Guest
Posts: n/a
 
      20th Nov 2006
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how copy formula that contains ranges so ranges do not overlap Patty Microsoft Excel Worksheet Functions 1 20th Nov 2008 04:15 PM
Copy data in named ranges to a newer version of the same template to identical ranges handstand Microsoft Excel Programming 0 21st Aug 2006 03:51 PM
Pasting to Large Ranges maxima Microsoft Excel Discussion 2 9th Jun 2006 03:57 PM
Pasting to disconnected ranges Viggy Microsoft Excel Worksheet Functions 1 30th Mar 2004 06:39 AM
Copy ranges and pasting in reverse order? steve Microsoft Excel Worksheet Functions 3 13th Jan 2004 05:49 PM


Features
 

Advertising
 

Newsgroups
 


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