View Single Post
 
Old 01-17-2024, 09:03 AM
Italophile Italophile is offline Windows 11 Office 2021
Expert
 
Join Date: Mar 2022
Posts: 554
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

An empty table cell isn't empty as it contains an end of cell mark which is a compound character with a text length of two characters. The routine below simply loops through the table checking the text length of each cell and applies the texture as necessary

Code:
Sub ApplyTableShading()
    Dim tbl As Table: Set tbl = ActiveDocument.Tables(2)
    Dim tRow As Row, tCell As Cell
    
    For Each tRow In tbl.Rows
        For Each tCell In tRow.Cells
            If Len(tCell.Range.Text) = 2 Then tCell.Shading.Texture = wdTextureDiagonalUp
        Next tCell
    Next tRow
End Sub
Reply With Quote