#1
|
|||
|
|||
A code to add fresh row after each odd row
First of all, thanks for your usual support.
I need a code that loops through current table and add one blank row after each odd row (first, third, etc.) Thanks a lot |
#2
|
|||
|
|||
Hi, Capitala! The code is quite simple:
Code:
Sub Tbl_Add_Rows() 'In the selected tbl, insert a row after each odd row. Dim LastRow As Integer Application.ScreenUpdating = False LastRow = selection.Tables(1).rows.count If LastRow Mod 2 = 0 Then LastRow = LastRow Else: LastRow = LastRow - 1 End If For i = LastRow To 2 Step -2 selection.Tables(1).rows(i).Select With selection.Tables(1).rows(i) selection.InsertRowsAbove 1 End With Next i Application.ScreenUpdating = True End Sub |
#3
|
|||
|
|||
Actually, it has inserted a row only after the first row, then it stopped
|
#4
|
|||
|
|||
Can't be! I've tested and retested it! Number the rows in the original table, then run the macro to see the result. As an afterthought, maybe your table has merged rows/columns?
|
#5
|
|||
|
|||
I appreciate of you send me the document on which you've tested the code?
Thanks in advance |
#6
|
|||
|
|||
Now it's quite Perfect. Thanks
|
#7
|
|||
|
|||
Nice! You are welcome!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
I want to start fresh | wweissborn | OneNote | 0 | 04-10-2024 03:44 PM |
fresh install - excel and outlook won't appear in defaults | gtr851 | Office | 0 | 11-30-2020 06:41 PM |
Fresh reload of Outlook 2007 doesn't allow me to "delete" messages in my IN box | Richardbye | Outlook | 0 | 05-20-2018 11:30 PM |
2013 issues opening files after fresh instal | dversion1 | Office | 0 | 10-06-2013 09:38 AM |
Generating Fresh Copies Of an Excel Document | callumwk | Excel | 2 | 04-09-2012 06:13 AM |