Insert new row with above active cell using vba excel

Iarianna81

New Member
Joined
Nov 22, 2017
Messages
6
Hi ,

i have data in column A, B ,C but i need to insert new row above active cell in coloum B

original format
[TABLE="width: 211"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]APPLE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]SUGAR[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]MILK[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]WATER[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]BANANA[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]SUGAR[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]MILK[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]WATER[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]MANGGO[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]SUGAR[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]MILK[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]WATER[/TD]
[/TR]
</tbody>[/TABLE]


I found some macro using below code
Sub InsertRows()


Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Range("B3", Range("B" & Rows.Count).End(xlUp))

.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(1), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
.Offset(2, -1).SpecialCells(xlCellTypeConstants).Offset(, 1).ClearContents
.Offset(, -1).EntireColumn.Delete
.EntireColumn.RemoveSubtotal

End With

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub



below data after i run this code...row insert below active cell...not above cell

[TABLE="width: 211"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]APPLE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]SUGAR[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]MILK[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]WATER[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]BANANA[/TD]
[TD]

[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]SUGAR[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]MILK[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]WATER[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]MANGGO[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]SUGAR[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]MILK[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]WATER[/TD]
[/TR]
</tbody>[/TABLE]


what i need is
[TABLE="width: 211"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]APPLE[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]SUGAR[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]MILK[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]WATER[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]BANANA[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]SUGAR[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]MILK[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]WATER[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]MANGGO[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]SUGAR[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]MILK[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD]WATER[/TD]
[/TR]
</tbody>[/TABLE]

Thanks for your advance
***Kt***
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top