'xlPasteValues and xlPasteFormats at the same time
I am copying a range and then pasting it's values and formats to another range:
ws5.Range("F3:N" & xCell).SpecialCells(xlCellTypeVisible).Copy
ws16.Cells(Rows.Count, "B").End(xlUp).Offset(4, 0).PasteSpecial xlPasteValues
ws16.Cells(Rows.Count, "B").End(xlUp).Offset(4, 0).PasteSpecial xlPasteFormats
Is it possible to do these two paste actions in one action without using With?
I would like to increase the speed of my macro and that kind of small reduction might help me.
Is there something like .PasteSpecial xlPasteValues and xlPasteFormats?
I found link but even this answer is using With, which is useless for me.
Solution 1:[1]
You can use it this way:
NewSheet.Range("A1").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
NewSheet.Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Place the two commands one after each other. First, you have to paste all, then you paste again, but only values and number formats.
Solution 2:[2]
You are looking for:
xlPasteValuesAndNumberFormats
edit## This is not the correct answer.
Solution 3:[3]
xlPasteAll
(Actually, since xlPasteAll is the default paste option, you can just leave it off.)
Source: https://msdn.microsoft.com/en-us/library/aa195818(v=office.11).aspx
Solution 4:[4]
You can paste the content several times to get what you need, like
Cells(1, 1).PasteSpecial Paste:=xlPasteAll
Cells(1, 1).PasteSpecial Paste:=xlPasteValues
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Adrian Mole |
| Solution 2 | |
| Solution 3 | MarredCheese |
| Solution 4 | user4375438 |
