Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-08-2021, 07:14 AM
mc1903 mc1903 is offline Change Table Style from Table 5 Onwards. Windows 10 Change Table Style from Table 5 Onwards. Office 2016
Novice
Change Table Style from Table 5 Onwards.
 
Join Date: Jan 2019
Posts: 8
mc1903 is on a distinguished road
Default Change Table Style from Table 5 Onwards.

Hi,

I am looking to swap the table style for table #5 onwards only if it matches a specific style.

This changes the style for ALL tables with using the 'Bad Table 1'; which includes tables 2 & 3 which I need to keep as the 'Bad Table 1' style (long boring story).

I am sure it is something stupid; but my VBA skills are basic and I am frankly amazed I got this far!

Anyone have 10 mins to help me please?

Code:
Sub Table5OnwardSwap()
    Application.ScreenUpdating = False
    Dim tblcount As Integer
    Dim tbl As Table
    For tblcount = 5 To ActiveDocument.Tables.Count
        For Each tbl In ThisDocument.Tables
            If tbl.Style = "Bad Table 1" Then
                tbl.Style = "Grid Table 4 - Accent 1"
                tbl.ApplyStyleRowBands = False
            End If
        Next
    Next
    Application.ScreenUpdating = True
    Set tbl = Nothing
End Sub
Any pointers will be appreciated.

Thanks
M
Reply With Quote
  #2  
Old 01-08-2021, 08:36 AM
mc1903 mc1903 is offline Change Table Style from Table 5 Onwards. Windows 10 Change Table Style from Table 5 Onwards. Office 2016
Novice
Change Table Style from Table 5 Onwards.
 
Join Date: Jan 2019
Posts: 8
mc1903 is on a distinguished road
Default

Managed to 'fix' it myself with some Power Googling :-)

Code:
Sub Table5OnwardSwap()
    Application.ScreenUpdating = False
    Dim tblcount As Integer
    Dim tbl As Table
    For tblcount = 5 To ThisDocument.Tables.Count
        Set tbl = ThisDocument.Tables(tblcount)
            If tbl.Style = "Bad Table 1" Then
                tbl.Style = "Grid Table 4 - Accent 1"
                tbl.ApplyStyleRowBands = False
            End If
    Next
    Application.ScreenUpdating = True
    Set tbl = Nothing
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Table Style from Table 5 Onwards. Want to copy & paste a table underneath itself x no. of time, table found through style heading name fly545 Word VBA 11 01-16-2020 05:53 PM
When changing table style in Word 2010, font size seems to change but doesn't show in new tables heartsoulliving Word 1 12-07-2016 05:17 PM
Change Table Style from Table 5 Onwards. how to apply table style WITHOUT setting it as a table? dylansmith Excel 9 05-16-2014 07:25 PM
Can't change color of text in table style ABode Word 6 12-03-2013 07:45 AM
How to change style of text in table? SCMiller Word VBA 1 04-24-2012 08:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:56 AM.


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