-
range copy with paste
OK, I admit I read somewhere to avoid copy/paste. I want to copy a row of data from one worksheet to another. First I copy the header row. But it copies only the data and I want things like column width copied as well. I can't seem to find the correct parameter to use to make it copy everything.
wsNewM.rows(1) = wsOldM.rows(1)
This was my first attempt and it moved nothing. So I added the ".Value" as such:
wsNewM.rows(1).Value = wsOldM.rows(1).Value
This copies the data but nothing else. (wsNewM and wsOldM are both worksheets and properly declared.)
I also notice that VBE religiously changes my capitalization of "Rows" to "rows". Why? I thought this was some kind of object readability issue.
Thanks
-
Code:
Sub a()
wsOldM.Rows(1).Copy wsNewM.Rows(1)
End Sub
-
Thank you Patel. The code does indeed perform as expected.
I'm curious because I thought this used the clipboard (because of ".Copy"). Does this construction avoid the clipboard? Does this mean that the clipboard is used only when the "Paste" or "PasteSpecial" is used?
Thanks again.
-
I think my code uses the clipboard for copying, but erases it after execution.
You can have the same result with
Code:
Sub a()
wsOldM.Rows(1).Copy
wsNewM.Rows(1) .paste
Application.CutCopyMode = False
End Sub
-
Thanks again. I'm definitely trying to avoid using the clipboard.