The information in this article applies to:
SYMPTOMSWhen you use the following Visual Basic, Applications Edition, command in a macro
in conjunction with the Copy and Paste methods, you may receive the
following unexpected results:
-or- CAUSE
When you use a macro to paste data in a worksheet, and you then attempt to
paste another selection to the same worksheet, if you do not make a new
selection for the range that you want to paste to, the copied data is
pasted to the range that you previously pasted to. For example, if you copy
one column of cells, and the last range you pasted to contained three
columns, when you use the Paste method without making another selection,
the three columns are filled with the single column of data you copied.
WORKAROUNDTo work around this problem, create a variable for your selection, and use the Resize method to make the destination range the desired size. For example, to create a destination range that is offset by the number of columns in your selection, but is resized to one column, use the following code:
MORE INFORMATIONSteps to Reproduce Behavior
To edit this macro so that the data is copied correctly, replace the line
of code that reads:
-with-
When you run the macro with this change included, the copied data is pasted
once into the correct paste range.
Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft Support professionals can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400. Additional query words: 5.00c 7.00a
Keywords : kbprg |
Last Reviewed: October 22, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |