ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste Special (https://www.excelbanter.com/excel-programming/379826-paste-special.html)

Michael M

Paste Special
 
Hii All
The following code works fine:
range("F12").Copy
range("F13:F" & lrow - 1).PasteSpecial (xlPasteFormats)

I tried to reduce it to the following and it gives an App error:
range("F12").Copy range("F13:F" & lrow - 1).PasteSpecial(xlPasteFormats)

It seems to be quite happy to accept the line of code when I type it in.
Where is it wrong ??
Any advice is appreciated
Regards
Michael M

Michael M

Paste Special
 
Thanks Martin
I read through my code books and basically there was no reference to what I
was trying to do.....which usually means, very difficult to do.
I appreciate your input but don't think for my small needs it will be
necessary.
I was simply trying to "clean up" my existing code.

Regards
Michael M

"Martin Fishlock" wrote:

You cannot reduce the paste special code. The copy command either copies the
source to the clipboard or to a destination using the normal paste conditions.

A solution is to write a subroutine to do a copy paste

Sub mycopypaste(CopyFrom As Range, CopyTo As Range, PasteConditions)
CopyFrom.Copy
CopyTo.PasteSpecial PasteConditions
End Sub

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Michael M" wrote:

Hii All
The following code works fine:
range("F12").Copy
range("F13:F" & lrow - 1).PasteSpecial (xlPasteFormats)

I tried to reduce it to the following and it gives an App error:
range("F12").Copy range("F13:F" & lrow - 1).PasteSpecial(xlPasteFormats)

It seems to be quite happy to accept the line of code when I type it in.
Where is it wrong ??
Any advice is appreciated
Regards
Michael M



All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com