Hello Guys, below is code that I've built that inserts a row or rows depending on the selection from the user. This works ok but is lacking a few things to make it perfect.
1st issue: Using the code below, the rows get inserted either above or below the ACTIVE cell. Id like it to just find the last used cell in column "A" above the totals row and do the insert there. (last row needs to stay the last row by just moving down, there is no data in column A on the totals row)
2nd issue: When the code does the copy, paste, I'm not getting the formulas or the borders in the inserted rows. Id like it to copy just the format and the formulas into the rows pasted.
Any assistance is GREATLY appreciated
Sub Button2_Click()
Dim N As Long, x As String, y As String
Set Target = ActiveCell
x = InputBox("please, select the number of rows", "add new rows", "1")
If x = "" Then Exit Sub
x = Val(x)
y = InputBox("please, select:" & vbCr & "Below = 1" & vbCr & "Above= 2", _
"add new rows above/below", "1")
If y = "" Then Exit Sub
Select Case y
Case Is = "1"
For N = 1 To x
Target.EntireRow.Copy
Target.Offset(1).EntireRow.Insert shift:=xlUp
Next
Case Is = "2"
For N = 1 To x
Target.EntireRow.Insert shift:=xlUp
Next
End Select
Target.Offset(, 1).Select
End Sub
Display More
[TABLE="border: 1, cellpadding: 1, width: 500"]
DATA
[/td]DATA
[/td]DATA
[/td]DATA
[/td]DATA
[/td]DATA
[/td]INSERT ROW
[/td]INSERT ROW
[/td]INSERT ROW
[/td]NO DATA
[/td]SUBTOTALS
[/td]TOTALS
[/td]
[/TABLE]
Hope this helps and makes sense