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


Trying to copy "contents only" using the following code.
Having errors.. etc.. Any help??


Worksheets("Invoice").Range(2, "A:M").Copy
Destination = Worksheets("Master").Range(7, "A:M")


Thanks,

Me

--
Metraza
-----------------------------------------------------------------------
Metrazal's Profile: http://www.excelforum.com/member.php...fo&userid=3164
View this thread: http://www.excelforum.com/showthread.php?threadid=51844

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy contents only

What did you want to copy A2:M2?

Worksheets("Invoice").Range("a2:m2").Copy
worksheets("master").range("a7:m7").pastespecial paste:=xlpastevalues

or

worksheets("master").range("a7:m7").value _
= worksheets("invoice").range("a2:m2")



Metrazal wrote:

Trying to copy "contents only" using the following code.
Having errors.. etc.. Any help??

Worksheets("Invoice").Range(2, "A:M").Copy
Destination = Worksheets("Master").Range(7, "A:M")

Thanks,

Met

--
Metrazal
------------------------------------------------------------------------
Metrazal's Profile: http://www.excelforum.com/member.php...o&userid=31648
View this thread: http://www.excelforum.com/showthread...hreadid=518444


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy contents only


Thats it..

Thanks,

Met


--
Metrazal
------------------------------------------------------------------------
Metrazal's Profile: http://www.excelforum.com/member.php...o&userid=31648
View this thread: http://www.excelforum.com/showthread...hreadid=518444

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy contents only


I adjusted the code to allow multiple fields. However, I have an error.
Wheres my problem?


For i = 1 To 9999
Worksheets("Invoice").Range(i, "a2:m2").Copy
Worksheets("master").Range(i, "a7:m7").PasteSpecial
Paste:=xlPasteValues
Next i


Thanks,

Met


--
Metrazal
------------------------------------------------------------------------
Metrazal's Profile: http://www.excelforum.com/member.php...o&userid=31648
View this thread: http://www.excelforum.com/showthread...hreadid=518444

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy contents only

This doesn't work:
..Range(i, "a2:m2")

Are you trying to copy A2:M10000 to A7:M10006?

If yes, then just do it all at once:

Worksheets("Invoice").Range("a2:m10000").Copy
worksheets("master").range("a7").pastespecial paste:=xlpastevalues

Excel is smart enough to resize the destination range to match the copied range.

or

Dim RngToCopy as range
dim DestCell as range
set rngtocopy = worksheets("invoice").range("a2:m10000")
set destcell = worksheets("master").range("a7")

with rngtocopy
destcell.resize(.rows.count,.columns.count).value _
= .value
end with


Metrazal wrote:

I adjusted the code to allow multiple fields. However, I have an error.
Wheres my problem?

For i = 1 To 9999
Worksheets("Invoice").Range(i, "a2:m2").Copy
Worksheets("master").Range(i, "a7:m7").PasteSpecial
Paste:=xlPasteValues
Next i

Thanks,

Met

--
Metrazal
------------------------------------------------------------------------
Metrazal's Profile: http://www.excelforum.com/member.php...o&userid=31648
View this thread: http://www.excelforum.com/showthread...hreadid=518444


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy contents only


That did it..

Thanks again,
Me

--
Metraza
-----------------------------------------------------------------------
Metrazal's Profile: http://www.excelforum.com/member.php...fo&userid=3164
View this thread: http://www.excelforum.com/showthread.php?threadid=51844

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Copy contents only

Met,

Not sure what your trying to do with Range(2,"A:M") - do you mean
Range("A2:M2")?

Your code, if corrected, will copy the entire cells (formula, formats etc).

If you want to copy just the cell values, easiest way (rather than using
paste special) is to use a temporary array to store the values:

Dim tmpArr As Variant

tmpArr = Worksheets("Invoice").Range("A2:M2")
Worksheets("Master").Range("A7:M7") = tmpArr


HTH

Tim


"Metrazal" wrote in
message ...

Trying to copy "contents only" using the following code.
Having errors.. etc.. Any help??


Worksheets("Invoice").Range(2, "A:M").Copy
Destination = Worksheets("Master").Range(7, "A:M")


Thanks,

Met


--
Metrazal
------------------------------------------------------------------------
Metrazal's Profile:

http://www.excelforum.com/member.php...o&userid=31648
View this thread: http://www.excelforum.com/showthread...hreadid=518444



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
Copy contents from one cell to another Don[_4_] New Users to Excel 0 September 25th 09 04:18 PM
Copy cell contents with VB TheMilkGuy Excel Discussion (Misc queries) 6 July 21st 09 11:46 PM
Copy contents if....... Metrazal Excel Programming 2 February 16th 06 08:39 PM
Copy Contents of 3 Columns into 1 Lynxen Excel Programming 4 July 13th 05 01:19 PM
Copy textbox contents Stuart[_5_] Excel Programming 2 August 15th 04 06:57 PM


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