View Full Version : Insert 'n' number Rows after any specified row no.
LalitPandey87
10-05-2011, 04:37 PM
Hi All,
I need a VBA Function which takes the "specified row number" and "Number of rows to be inserted" as a parameter.
Please Help
Thanx in Advance.
Admin
10-05-2011, 08:02 PM
Hi Mohan,
Try this
Sub InsertRows(ByVal RowNo As Long, ByVal NoOfRows As Long, Optional ByVal Sht As Worksheet)
Dim lngSU As Long
Dim lngCalc As Long
With Application
lngSU = .ScreenUpdating
.ScreenUpdating = False
.EnableEvents = False
lngCalc = .Calculation
.Calculation = xlCalculationManual
End With
If Sht Is Nothing Then Set Sht = ActiveSheet
Sht.Rows(RowNo).Resize(NoOfRows).Insert
With Application
.ScreenUpdating = lngSU
.EnableEvents = True
.Calculation = lngCalc
End With
End Sub
and call the routine like..
Sub Test()
InsertRows 10, 5
End Sub
LalitPandey87
11-08-2011, 08:59 AM
Thanx for this useful function.
Working!
:cool:
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.