Option Explicit'Worksheet.paste Method'Pastes the contents of the Clipboard onto the worksheet. 'an expression. Paste (Destination, Link)'An expression is a variable that represents a Worksheet object. Subpaste () Range ("B1:b6"). Copy Range ("C9")'This sentence is equal to the following two sentences, but the following two sentences are also usefulRange ("B1:b6"). Copy'copy Area no formulaSheet1.paste Range ("C9")'paste into cell C4End SubSubpaste 2 () Range ("C1:c6"). Copy'copy cells with formulasSheet3.paste'If you do not specify the Destination parameter, you must select the target region before using the method. End SubSubPaste 1 ()'This is interesting, in the way of the link, the mother changes, the sub-body also changedRange ("C1:c6"). Copy'Copy C1 cellsSheet3.paste,True 'of course, the target area must be selected before using this methodApplication.cutcopymode =True 'either write true or false here to remove the copy border'action to remove a border after copyEnd Sub
Paste selectively: range.pastespecial
In most cases we may just want to paste the area content instead of its format, or vice versa.
' Range.pastespecial method
' Pastes a range from the Clipboard into the specified area.
' Grammar
' Expression. PasteSpecial (Paste, operation, Skipblanks, transpose)
' Expression A variable that represents a Range object.
SubSelect Blame paste ()'do not paste the formula, just paste the contentRange ("C2:C10"). Copyrange ("D2"). PasteSpecial A '12 for paste values and number formatsEnd SubSubSelect Strange paste operation ()'2 = Paste as "add"'The final result is a total of two regions addedRange ("b2:b9"). Copyrange ("D2"). PasteSpecial,2Range ("c2:c9"). Copyrange ("D2"). PasteSpecial,2End SubSubSelect strange paste Skip Empty cell () Range ("b2:b9"). Copyrange ("E2"). PasteSpecial,,True 'Skip Ahead, select True at SkipblankEnd SubSubpaste the transpose () Range selectively ("a2:b9"). Copyrange ("A11"). PasteSpecial A, , ,TrueEnd Sub
Give the part:
How to paste VBA learning notes