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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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