View Single Post
 
Old 10-22-2013, 07:09 AM
C J Squibb C J Squibb is offline Windows 7 64bit Office 2010 32bit
Novice
 
Join Date: Aug 2013
Location: Essex
Posts: 14
C J Squibb is on a distinguished road
Default Add multiple rows to Excel 2010 table at cursor position

I am trying to add multiple rows to my Excel table (the number to be specified by an inputbox). The rows should go in starting at the current cursor position. I want to add Table rows, not worksheet rows.

My first problem was that I found myself unable to identify the current table row using [#This Row], so have had to resort to using absolute row numbers, subtracting the header row from the current worksheet row to give me the table row number. Using this, I can add a single row at my required location with this line of code:
Code:
Selection.ListObject.ListRows.Add (intCurRow - intHeader)
However, the code simply exits at this point, so I can't use a For...Next or Do...Until loop to add multiple rows.

Is there a way to add multiple table rows with a single command, or to make this code run round a loop?
Reply With Quote