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]
[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
[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***
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***