Hello all,
I have a section in my sheet for the user to add product descriptions. The range of cells is E25 to H25 (header) E26 to H25 (first line of data).
There is data adjacent to the range so I need to shift the cells down and not insert an entire row. I found the add a row code on the net and a line of code that is supposed to shift the cells down that I have integrated into the code.
This is the code I have been trying but excel is still adding a complete row. Can you please suggest/specify the proper VBA code to shift the cell range down without adding an entire row?
Thanks,
Rob
Sub addNewRow()
' Do not insert a row before the first row.
Dim iTopRow As Integer
iTopRow = 1
If (ActiveCell.Row > iTopRow) Then
' Get the active row number.
Dim rowNum As Integer
rowNum = ActiveCell.Row
Rows(27).Insert shift:=xlShiftDown ' Insert a new row.
' Change the Codes (in first column).
Cells(ActiveCell.Row, 1) = rowNum - 1 ' For the active cells.
Dim iTotalRows As Integer ' Get the total used range rows.
iTotalRows = ActiveSheet.UsedRange.Rows.Count
Dim iRows As Integer
For iRows = rowNum + 1 To iTotalRows
Cells(iRows, 1) = iRows - 1
Next iRows
End If
End Sub
[Moved from Office/Excel/Windows 10/Office 365 for business]