Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Copy/Paste Values code

Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code below is
what I'm using now but it seems that there should be a simpler way. Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Copy/Paste Values code

Give this a try...

Sub CopySheets()
Sheets("Sheet2").Cells.Copy Sheets("Sheet1").Range("A1")
End Sub

--
Rick (MVP - Excel)


"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code below
is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Copy/Paste Values code

Hi,

Maybee this

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy
Sheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteValues
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Jules" wrote:

Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code below is
what I'm using now but it seems that there should be a simpler way. Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Copy/Paste Values code

Yes. Thanks!!

"Mike H" wrote:

Hi,

Maybee this

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy
Sheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteValues
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Jules" wrote:

Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code below is
what I'm using now but it seems that there should be a simpler way. Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Copy/Paste Values code

Might be a little faster.

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet1").Range("A1")
End Sub



"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code below
is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Copy/Paste Values code

Using the UsedRange might not be what the OP wants. If the UsedRange does
not start at A1, then using it in your code will move all the data up so
that the data starts in A1; using Cells as I proposed will keep the moved
data in the same cells they currently are in. Try this experiment with both
options to see the difference. Fill Sheet 1 with some data, then select the
first 5 rows and click Edit/Clear/All on the menu bar (do not just hit the
Delete key) to clear those cells from the UsedRange., then run your code and
watch where Row 6's data (and all the rows after it) end up. Now repeat the
process using my code.... Row 6 and all following rows remain in the same
rows they currently are in on Sheet2.

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
Might be a little faster.

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet1").Range("A1")
End Sub



"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code
below is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Copy/Paste Values code

Hi,

It will be faster but the OP noted in the header and example code that it
was values the were to be pasted.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"JLGWhiz" wrote:

Might be a little faster.

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet1").Range("A1")
End Sub



"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code below
is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub




.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Copy/Paste Values code

The OP used A1 as the destination cell. I just followed their lead.


"Rick Rothstein" wrote in message
...
Using the UsedRange might not be what the OP wants. If the UsedRange does
not start at A1, then using it in your code will move all the data up so
that the data starts in A1; using Cells as I proposed will keep the moved
data in the same cells they currently are in. Try this experiment with
both options to see the difference. Fill Sheet 1 with some data, then
select the first 5 rows and click Edit/Clear/All on the menu bar (do not
just hit the Delete key) to clear those cells from the UsedRange., then
run your code and watch where Row 6's data (and all the rows after it) end
up. Now repeat the process using my code.... Row 6 and all following rows
remain in the same rows they currently are in on Sheet2.

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
Might be a little faster.

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet1").Range("A1")
End Sub



"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code
below is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub







  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Copy/Paste Values code

Rick,

Good point about the difference between usedrange and cells but yours and
JLGWhiz options don't paste values as the OP requested.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Rick Rothstein" wrote:

Using the UsedRange might not be what the OP wants. If the UsedRange does
not start at A1, then using it in your code will move all the data up so
that the data starts in A1; using Cells as I proposed will keep the moved
data in the same cells they currently are in. Try this experiment with both
options to see the difference. Fill Sheet 1 with some data, then select the
first 5 rows and click Edit/Clear/All on the menu bar (do not just hit the
Delete key) to clear those cells from the UsedRange., then run your code and
watch where Row 6's data (and all the rows after it) end up. Now repeat the
process using my code.... Row 6 and all following rows remain in the same
rows they currently are in on Sheet2.

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
Might be a little faster.

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet1").Range("A1")
End Sub



"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code
below is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub





.

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Copy/Paste Values code

Rick,

I meant to add that a neat solution would be

Sheets("Sheet1").Cells.Value Sheets("Sheet2").Cells.Value

Unfortunately; at least on my pc, I get an out of memory error so have to
limit the range with say

Sheets("Sheet1").Range("A1:d20").Value =
Sheets("Sheet2").Range("A1:d20").Value

The latter approach is (i think) frought with danger because you may be able
to set up the correct range by finding the last row and column but there's no
way i know of establishing any memory limitation on the host computer which
is why I don't bother with the 'single line' approach for pasting values.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Rick Rothstein" wrote:

Using the UsedRange might not be what the OP wants. If the UsedRange does
not start at A1, then using it in your code will move all the data up so
that the data starts in A1; using Cells as I proposed will keep the moved
data in the same cells they currently are in. Try this experiment with both
options to see the difference. Fill Sheet 1 with some data, then select the
first 5 rows and click Edit/Clear/All on the menu bar (do not just hit the
Delete key) to clear those cells from the UsedRange., then run your code and
watch where Row 6's data (and all the rows after it) end up. Now repeat the
process using my code.... Row 6 and all following rows remain in the same
rows they currently are in on Sheet2.

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
Might be a little faster.

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet1").Range("A1")
End Sub



"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code
below is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub





.



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Copy/Paste Values code

Good point about the values. How about this then...

Sub CopySheets()
With Sheets("Sheet1")
Sheets("Sheet2").Cells.Copy .Range("A1")
.UsedRange.Value = .UsedRange.Value
End With
End Sub

Notice using UsedRange in the second line of code inside the With block is
fine because the cells are already in place at that point of the code.

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
Rick,

Good point about the difference between usedrange and cells but yours and
JLGWhiz options don't paste values as the OP requested.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Rick Rothstein" wrote:

Using the UsedRange might not be what the OP wants. If the UsedRange does
not start at A1, then using it in your code will move all the data up so
that the data starts in A1; using Cells as I proposed will keep the moved
data in the same cells they currently are in. Try this experiment with
both
options to see the difference. Fill Sheet 1 with some data, then select
the
first 5 rows and click Edit/Clear/All on the menu bar (do not just hit
the
Delete key) to clear those cells from the UsedRange., then run your code
and
watch where Row 6's data (and all the rows after it) end up. Now repeat
the
process using my code.... Row 6 and all following rows remain in the same
rows they currently are in on Sheet2.

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
Might be a little faster.

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet1").Range("A1")
End Sub



"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data
into
another existing worksheet? I do NOT want to rename the sheets. Code
below is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub





.


  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Copy/Paste Values code

Yeah, I caught that, Mike, but you had already handled it.


"Mike H" wrote in message
...
Rick,

Good point about the difference between usedrange and cells but yours and
JLGWhiz options don't paste values as the OP requested.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Rick Rothstein" wrote:

Using the UsedRange might not be what the OP wants. If the UsedRange does
not start at A1, then using it in your code will move all the data up so
that the data starts in A1; using Cells as I proposed will keep the moved
data in the same cells they currently are in. Try this experiment with
both
options to see the difference. Fill Sheet 1 with some data, then select
the
first 5 rows and click Edit/Clear/All on the menu bar (do not just hit
the
Delete key) to clear those cells from the UsedRange., then run your code
and
watch where Row 6's data (and all the rows after it) end up. Now repeat
the
process using my code.... Row 6 and all following rows remain in the same
rows they currently are in on Sheet2.

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
Might be a little faster.

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet1").Range("A1")
End Sub



"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data
into
another existing worksheet? I do NOT want to rename the sheets. Code
below is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub





.



  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Copy/Paste Values code

This problem can be solved like this:

Sub CopySheets()
r = Sheets("Sheet2").UsedRange.Row
c = Sheets("Sheet2").UsedRange.Column
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet3").Cells(r, c)
End Sub

Mishell

"Rick Rothstein" a écrit dans le
message de news: ...
Using the UsedRange might not be what the OP wants. If the UsedRange does
not start at A1, then using it in your code will move all the data up so
that the data starts in A1; using Cells as I proposed will keep the moved
data in the same cells they currently are in. Try this experiment with
both options to see the difference. Fill Sheet 1 with some data, then
select the first 5 rows and click Edit/Clear/All on the menu bar (do not
just hit the Delete key) to clear those cells from the UsedRange., then
run your code and watch where Row 6's data (and all the rows after it) end
up. Now repeat the process using my code.... Row 6 and all following rows
remain in the same rows they currently are in on Sheet2.

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
Might be a little faster.

Sub CopySheets()
Sheets("Sheet2").UsedRange.Copy Sheets("Sheet1").Range("A1")
End Sub



"Jules" wrote in message
...
Is there a faster way to copy and paste one entire worksheets data into
another existing worksheet? I do NOT want to rename the sheets. Code
below is
what I'm using now but it seems that there should be a simpler way.
Thanks!

Sub CopySheets()
Sheets("Sheet2").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub







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
Find matching values, copy/paste values as well as values in ColA ryguy7272 Excel Programming 2 September 28th 09 06:20 AM
What code for repeatedly copy, paste values ?? colwyn[_13_] Excel Programming 0 November 26th 08 09:39 PM
VBA code to copy and paste by values from one Excel workbook to another Nhien Excel Programming 7 August 17th 07 04:06 PM
code to FIND value, copy, paste values onto other sheet ufo_pilot Excel Programming 2 December 6th 05 04:14 PM
How do i compare values from two sheet and copy & paste if values match? rozb Excel Programming 0 March 5th 04 12:06 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"