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
ABC
4APPLE
SUGAR
MILK
WATER
5BANANA
SUGAR
MILK
WATER
10MANGGO
SUGAR
MILK
WATER

<colgroup><col><col><col></colgroup><tbody>
</tbody>


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

ABC
4APPLE
SUGAR
MILK
WATER
5BANANA

SUGAR
MILK
WATER
10MANGGO
SUGAR
MILK
WATER

<colgroup><col><col><col></colgroup><tbody>
</tbody>


what i need is
ABC
4APPLE
SUGAR
MILK
WATER
5BANANA
SUGAR
MILK
WATER
10MANGGO
SUGAR
MILK
WATER

<colgroup><col><col><col></colgroup><tbody>
</tbody>

Thanks for your advance
***Kt***
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

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