Consulting

Results 1 to 4 of 4

Thread: How to hide blank rows in a Powerpoint table using vba macro?

  1. #1
    VBAX Regular
    Joined
    Apr 2017
    Posts
    6
    Location

    How to hide blank rows in a Powerpoint table using vba macro?

    I'm new to VBA macros and trying to write a macro to hide the blank rows
    in a Powerpoint table. I'm not sure which properties to use and how to
    move on. Any help is highly appreciated. Thanks.


    Sub TableRowHide()

    Dim sl as Slide
    Dim shTable as Shape
    Dim pres as Presentation
    Dim irow as Integer
    Dim icol as Integer
    Dim counter as Integer

    Set pres = ActivePresentation

    With sh.Table

    For irow = 1 to .Rows.Count
    counter = 0
    For icol = 1 to .Columns.Count

    If shTable.table.Cell(irow,icol).Shape.Textframe.Textrange.Text = ""
    Then --------------

    counter = counter + 1
    End If

    If counter = .Columns.Count Then --------

    Else ------------

    Next icol

    Next irow

    End With

    End Sub

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Something like this maybe (for a selected table) NOTE blank rows are deleted - I don't believe you can just hide rows as you can in Excel.

    Sub zap_emptyRow()
    Dim otbl As Table
    Dim iRow As Integer
    Dim iCol As Integer
    Dim b_Text As Boolean
    
    
    On Error Resume Next
    Set otbl = ActiveWindow.Selection.ShapeRange(1).Table
    If Not otbl Is Nothing Then
    For iRow = otbl.Rows.Count To 1 Step -1
    b_Text = False
    For iCol = 1 To otbl.Columns.Count
    If otbl.Cell(iRow, iCol).Shape.TextFrame.HasText Then b_Text = True
    Next iCol
    If Not b_Text Then otbl.Rows(iRow).Delete
    Next iRow
    Else
    MsgBox "Something is wrong!"
    End If
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Apr 2017
    Posts
    6
    Location
    Hi John,

    Thanks for your script. As you indicated, this seems to delete rows rather than hide. I guess it's hard to hide the rows in Powerpoint unlike in Excel. Thanks a bunch!!

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Yep, there's no way to just hide rows. (That I know of!)
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •