Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2018, 08:31 PM
Authorized User
 
Join Date: Dec 2009
Posts: 69
Thanks: 6
Thanked 0 Times in 0 Posts
Default Copy and Paste

Hi,

I have a workbook made up of 5 worksheets, and I just wish to copy a range in each of the four worksheets and paste them into the fifth. The code is:
Code:
Worksheets("Option 3").Range("H11:H60").Copy Worksheets("Comparison").Range("B15")
Application.CutCopyMode = False

Worksheets("Option 1").Range("J11:H60").Copy Worksheets("Comparison").Range("D16")
Worksheets("Option 2").Range("J11:H60").Copy Worksheets("Comparison").Range("E16")
Worksheets("Option 3").Range("J11:H60").Copy Worksheets("Comparison").Range("G15")
Worksheets("Option 4").Range("J11:H60").Copy Worksheets("Comparison").Range("H15")
For reasons I don't understand the first range (H11:H60) is pasted in each of the following destinations D16, E16, G15 and H15 and my questions are why the clipboard is not cleared with Application.CutCopyMode = False, and the other copied ranges (J11:H60) are ignored, and the first range keeps pasting itself into the target destinations?
Finally the last range in Option 4 is pasted into a destination not mentioned in the code, which is J15.

I would appreciate your assistance in understanding this puzzle. Thank you
 
Old April 5th, 2018, 11:49 PM
Authorized User
 
Join Date: Oct 2015
Posts: 48
Thanks: 0
Thanked 5 Times in 5 Posts
Default Merged Source or Destination cells

That smells of Merged source or destination cells.

Double check that, if not then seperate the copy and the paste operations.
Wed have to see a snapshot of the source and destination to help
__________________
Nostalgia 4 Infinity
 
Old April 6th, 2018, 04:09 AM
Authorized User
 
Join Date: Dec 2009
Posts: 69
Thanks: 6
Thanked 0 Times in 0 Posts
Default Copy and Paste

You are right. It is my mistake.

Thank you very much for drawing my attention.





Similar Threads
Thread Thread Starter Forum Replies Last Post
copy paste aamish BOOK: Beginning Visual C# 2012 0 September 17th, 2016 12:05 AM
copy and paste jbroc Access VBA 0 April 21st, 2011 09:57 AM
Copy and Paste the value waka Excel VBA 7 October 28th, 2009 10:08 PM
copy paste !!!!!!! dpkbahuguna Beginning VB 6 1 March 30th, 2007 10:06 AM
Copy, Paste dpkbahuguna Beginning VB 6 1 October 26th, 2006 10:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.