[RESOLVED] How to Insert a row in Excel ?
I have an excel file with data from A1 to A10, how would I insert a row before lets say, Row 5 ?
I have this code:
VB Code:
Dim xlApp As Excel.Application
Dim wkbTemplateBook As Excel.Workbook
Dim wksTemplateSheet As Excel.Worksheet
Set xlApp = New Excel.Application
Set wkbTemplateBook = xlApp.Workbooks.Open(Me.txtTemplate.Text)
Set wksTemplateSheet = wkbTemplateBook.Worksheets(1)
With wksTemplateSheet
' how to insert a row ?
End With
Re: How to Insert a row in Excel ?
VB Code:
wksTemplateSheet .Rows("4:4").Select
Selection.Insert Shift:=xlDown
Re: How to Insert a row in Excel ?
Thanks RobDog888...
A not so important question: Is there a way to insert lets say 50 rows in one call ? or do I have to call the Insert 50 times in a loop ?
Re: How to Insert a row in Excel ?
What ever number of rows you select, that amount will be inserted. ;)
VB Code:
wksTemplateSheet.Rows("1:10").Select
Selection.Insert Shift:=xlDown
10 rows inserted.