Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2024, 11:49 PM
capitala capitala is offline A code to add fresh row after each odd row Windows 7 64bit A code to add fresh row after each odd row Office 2003
Advanced Beginner
A code to add fresh row after each odd row
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default 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
Reply With Quote
  #2  
Old Yesterday, 02:45 AM
vivka vivka is offline A code to add fresh row after each odd row Windows 7 64bit A code to add fresh row after each odd row Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 226
vivka is on a distinguished road
Default

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
Reply With Quote
  #3  
Old Yesterday, 02:53 AM
capitala capitala is offline A code to add fresh row after each odd row Windows 7 64bit A code to add fresh row after each odd row Office 2003
Advanced Beginner
A code to add fresh row after each odd row
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default

Actually, it has inserted a row only after the first row, then it stopped
Reply With Quote
  #4  
Old Yesterday, 02:58 AM
vivka vivka is offline A code to add fresh row after each odd row Windows 7 64bit A code to add fresh row after each odd row Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 226
vivka is on a distinguished road
Default

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?
Attached Images
File Type: png Test.png (2.6 KB, 8 views)
Reply With Quote
  #5  
Old Yesterday, 02:59 AM
capitala capitala is offline A code to add fresh row after each odd row Windows 7 64bit A code to add fresh row after each odd row Office 2003
Advanced Beginner
A code to add fresh row after each odd row
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default

I appreciate of you send me the document on which you've tested the code?
Thanks in advance
Reply With Quote
  #6  
Old Yesterday, 03:23 AM
capitala capitala is offline A code to add fresh row after each odd row Windows 7 64bit A code to add fresh row after each odd row Office 2003
Advanced Beginner
A code to add fresh row after each odd row
 
Join Date: Nov 2013
Posts: 31
capitala is on a distinguished road
Default

Now it's quite Perfect. Thanks
Reply With Quote
  #7  
Old Yesterday, 05:27 AM
vivka vivka is offline A code to add fresh row after each odd row Windows 7 64bit A code to add fresh row after each odd row Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 226
vivka is on a distinguished road
Default

Nice! You are welcome!
Reply With Quote
Reply



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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft