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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,224,747
Messages
6,180,708
Members
452,994
Latest member
Janick

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