Forum Discussion
paste special in vba not working
- May 28, 2022
PasteSpecial selects the range you paste to.
If you use range.Copy Destination:=other_range, that does not happen, so it would be better to use that.
As the name of the constant xlPasteValuesAndNumberFormats suggests, it causes Excel to paste values and number formats, but not any other formatting such as font name, font size, font color, fill color and borders. Sine the header row of the data sheet has General as number format, you're effectively only pasting values. If you want to paste formatting too, simply use
ws.Range("a1").PasteSpecial
HansVogelaar thank hans, one more question, after everything is copied, in all my new sheets created, i have last row selected, how to deselect it? i tried to put at end of code range("a1").select to select some other thing, but it didnt work, any suggestion?
- HansVogelaarMay 28, 2022MVP
PasteSpecial selects the range you paste to.
If you use range.Copy Destination:=other_range, that does not happen, so it would be better to use that.
- chahineMay 28, 2022Iron ContributorThanks Hans, these small things that i like to learn !