Change the text font size between "()"

zinah

Active Member
Joined
Nov 28, 2018
Messages
368
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a shape that contains text, what I need is to change the font size of any text between "()". How can I do that?

I was able to write below macro and it worked, however, the characters might change in future and I need to update below macro to cover this:

Code:
Sub Change_Font_Size()

    Set aSht = ActiveSheet
    Set p1sht = Sheets("Page1")
    Set p2Sht = Sheets("Page2")


    Dim shp As Shape
    
  
With p1sht.Shapes("Slide_Title")
    .TextFrame2.WordWrap = msoFalse
    .TextFrame2.TextRange.Font.Bold = msoTrue
    .TextFrame2.TextRange.Characters(1, 45).Font.Size = 22
    .TextFrame2.TextRange.Characters(46, 18).Font.Size = 16
    
End With


With p2Sht.Shapes("Slide_Title")
    .TextFrame2.WordWrap = msoFalse
    .TextFrame2.TextRange.Font.Bold = msoTrue
    .TextFrame2.TextRange.Characters(1, 33).Font.Size = 22
    .TextFrame2.TextRange.Characters(34, 41).Font.Size = 16
    
End With




End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
See if this does the first one

Code:
With p1sht.Shapes("Slide_Title")
    .TextFrame2.WordWrap = msoFalse
    .TextFrame2.TextRange.Font.Bold = msoTrue
    myText = .TextFrame2.TextRange.Text
    myStart = InStr(myText, "(")
    myEnd = InStr(myText, ")")
    If myStart > 0 And myEnd > 0 Then
        For i = 1 To Len(myText)
            If i < myStart Or i > myEnd Then
                .TextFrame2.TextRange.Characters(i).Font.Size = 22
            Else
                .TextFrame2.TextRange.Characters(i).Font.Size = 16
            End If
        Next
    Else
       .TextFrame2.TextRange.Characters(1, Len(myText)).Font.Size = 22
    End If
End With
 
Upvote 0

Forum statistics

Threads
1,223,755
Messages
6,174,318
Members
452,555
Latest member
colc007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top