I'm new to VBA and am looking for some additional assistance. I saw a previous post similar to my question but it's not working. Here's where I'm at:
- A7:N12 is a named range "trailer_req_lanes" A7:n8 are titles
- A13:N17 is a named range "trail_prod_queue" A13:N14 are titles
- A18:N21 is a named range "trailer_vendor_copack" A18:n19 are titles
- A22:n25 is a named range "trailer_storage" A22:n23 are titles
I want the file user to be able to add a blank line as needed to each named range. This means that the last line item in the range may or may not already have data in it. The blank line that is added should have the same format and formulas as the previous line and the range name should be adjusted for the new line.
I've tried the code several ways, attempting to use copy and pastespecial paste:=xlPasteFormulas but it's just not working. Here's what I have. Line 12 has data and when I run the code below it's copy and pasting all the date from row 12 to row 13. The named range update is working fine.
- A7:N12 is a named range "trailer_req_lanes" A7:n8 are titles
- A13:N17 is a named range "trail_prod_queue" A13:N14 are titles
- A18:N21 is a named range "trailer_vendor_copack" A18:n19 are titles
- A22:n25 is a named range "trailer_storage" A22:n23 are titles
I want the file user to be able to add a blank line as needed to each named range. This means that the last line item in the range may or may not already have data in it. The blank line that is added should have the same format and formulas as the previous line and the range name should be adjusted for the new line.
I've tried the code several ways, attempting to use copy and pastespecial paste:=xlPasteFormulas but it's just not working. Here's what I have. Line 12 has data and when I run the code below it's copy and pasting all the date from row 12 to row 13. The named range update is working fine.
Code:
Sub addnewrow_tractor_req_lanes()
Dim nameofrange As String
nameofrange = "tractor_req_lanes"
With Range(nameofrange)
With .Rows(.Rows.Count) 'goes to the last row in the range named
.copy
.Insert shift:=xlDown 'inserts a new row below the last row in the range named
.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range(.Offset(-1, 0), Range(nameofrange)).name = nameofrange
End With
End With
End Sub