Super new to VB macros. I have a title row with formatting that needs to be inserted periodically through my data. So basically I need to insert a static row of cells that is always at the top of my data, periodically throughout the below data.
How can I insert a static copied row of cells into any given row, and then shift the existing rows down?
Here is my attempt:
*Sub InsertTitles()
'
' InsertTitles Macro
'
' Keyboard Shortcut: Ctrl+Shift+V
'
ActiveCell.Range("A1:J1").Select
Selection.Copy
Selection.Insert Shift:=xlDown
End Sub*
replace your code with this.
Dim r As Range, n As Integer
n = ActiveCell.Row
Set r = Range("A" & n & ":J" & n)
r.Insert shift:=xlDown
r.Offset(-1, 0).Value = Range("A1: J1").Value
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.