I need help coming up with a small Macro that will let me copy cells A:G for the ActiveCell
row and Insert it into a new row below the ActiveCell
row. Currently the code that I have is:
ActiveSheet.Range(Cells(ActiveCell.Row,1),Cells(Active.Row,7)).Select
Selection.Copy
ActiveCell.Offset(1).EntireRow.Insert
But this ends up inserting a new row and copying the Selection
throughout the row which is not what I want. Any thoughts? Thanks!
With ActiveCell.Offset(1,-ActiveCell.Column+1).Resize(,7)
.Value = .Offset(-1).Value
End With
Your code does work except for the Active.Row
typo. It sounds like you're maybe intending to have an entire row inserted before copying the data. If so, otherwise preserving your method, you could use:
ActiveCell.Offset(1).EntireRow.Insert
ActiveSheet.Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 7)).Select
Selection.Copy
ActiveCell.Offset(1).Select
ActiveSheet.Paste
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.