Consulting

Results 1 to 3 of 3

Thread: Bolding total columns

  1. #1

    Bolding total columns

    Hello, I have a PowerPoint with a lot of data tables (one per slide), some of which have total columns that I would like to bold to differentiate from the other columns. I was able to do so using the below code that finds columns with "Total" in them and bolds them, but there are also some tables with total rows (i.e., "Total" in the first column), so it bolds those columns too, which I do not want. How do I make it so this only works for total columns (i.e., "Total" in the first row)?


    Sub Find_Change()
    Dim otbl As Table
    Dim R As Long
    Dim C As Long
    Dim osld As Slide
    Dim oshp As Shape
    Const target_Word As String = "Total" 
    For Each osld In ActivePresentation.Slides 
    For Each oshp In osld.Shapes 
    If oshp.HasTable Then 
    Set otbl = oshp.Table 
    For R = 1 To otbl.Rows.Count 
    For C = 1 To otbl.Columns.Count 
    If InStr(UCase(otbl.Cell(R, C).Shape.TextFrame2.TextRange.Text), UCase(target_Word)) > 0 Then Call boldcol(C, otbl) 
    Next C 
    Next R 
    End If 
    Next oshp 
    Next osld 
    End Sub 
    
    
    Sub boldcol(lngC As Long, otbl As Table) 
    Dim R As Long 
    For R = 1 To otbl.Rows.Count 
    With otbl.Cell(R, lngC).Shape.TextFrame2.TextRange.Font 
    .Bold = True 
    End With 
    Next 
    End Sub 
    Last edited by Aussiebear; 07-29-2022 at 03:05 PM. Reason: Added code tags to supplied code

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,057
    Location
    Maybe:

    Sub Find_Change()
    Dim otbl As Table
    Dim R As Long
    Dim C As Long
    Dim osld As Slide
    Dim oshp As Shape
    Const target_Word As String = "Total"
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    If oshp.HasTable Then
    Set otbl = oshp.Table
    For C = 1 To otbl.Columns.Count
    If InStr(UCase(otbl.Cell(1, C).Shape.TextFrame2.TextRange.Text), UCase(target_Word)) > 0 Then Call boldcol(C, otbl)
    Next C
    End If
    Next oshp
    Next osld
    End Sub
    
    
    
    
    Sub boldcol(lngC As Long, otbl As Table)
    Dim R As Long
    For R = 1 To otbl.Rows.Count
    With otbl.Cell(R, lngC).Shape.TextFrame2.TextRange.Font
    .Bold = True
    End With
    Next
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    That worked, thanks!

Posting Permissions

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