Darious
Darious

Reputation: 121

Alert if empty cell found in power point tables and in which slide using vba

I have to find and alert that if empty cell found in each tables in power point.

I have found the below code here, but it does not work and it should not be find for all table, not for selected one.

    Sub CheckTableCells()

    Dim oCell As Cell
    Dim oRow As Row
    Dim MyRange As Range

    For Each oRow In Selection.Tables(1).Rows
        For Each oCell In oRow.Cells
            If Selection.Text = Chr(13) & Chr(7) Then
                oCell.Select
                MsgBox oCell.RowIndex & " " & oCell.ColumnIndex & " is empty."
            End If
        Next oCell
    Next oRow

    End Sub

Please anyone help me for this.

enter image description here

Upvotes: 1

Views: 446

Answers (1)

TechnoDabbler
TechnoDabbler

Reputation: 1275

This code loops through each slide in the active presentation, and in each slide, check whether the each shape on the slide contains a table, and if it does, checks whether each cell is blank. Cheers.

Sub CheckTableCells()

    Dim vSlide As Slide
    Dim vShape As Shape
    Dim vRow As Long
    Dim vColumn As Long

    For Each vSlide In Application.ActivePresentation.Slides
        For Each vShape In vSlide.Shapes
            If vShape.HasTable Then
                For vRow = 1 To vShape.Table.Rows.Count
                    For vColumn = 1 To vShape.Table.Columns.Count
                        If vShape.Table.Cell(vRow, vColumn).Shape.TextFrame.TextRange.Text = "" Then
                            MsgBox vSlide.Name & " Table: """ & vShape.Name & """ cell (" & vRow & "," & vColumn & ") is blank."
                        End If
                    Next
                Next
            End If
        Next
    Next

End Sub

screen

Upvotes: 2

Related Questions