I’m building a macro to split a long table into multiple smalls tables, and I’d like to have the header saved in a variable to be able to quickly paste it on top of the smalls table.
I made a macro to do the first one (quite simple)
Sheets("Feuil1").Select
Rows("2:2").Select
Selection.Copy
Sheets("PageImpression").Select
Rows("2:2").Select
ActiveSheet.Paste
How can I keep my Selection.Copy in a variable and how do I paste it when I need to?
The answer is to store the row into a variable. Then call that variable when you need it. Also, no need for copy / paste and select and all that 🙂
Update
To use with a
RangeObject, do the following:Update 2
The even cleaner (memory + time saving) way to do this would be: