SavageStyle
SavageStyle

Reputation: 61

How i can add to existing cell additional text with modified font options in Microsoft Excel VBA

For example Microsoft VBA:

ActiveCell = ActiveCell & <Some Text i want to add with option Size = 20>

How i can implement that description inside "<>" brackets

Upvotes: 1

Views: 662

Answers (1)

marlenunez
marlenunez

Reputation: 626

You want to change the ActiveCell.Characters().Font property

Dim CurrentText, SomeText
Dim CurrentTextLen, SomeTextLen

CurrentText = ActiveCell.Value
CurrentTextLen = Len(CurrentText)

SomeText = "Some Text i want to add with option Size = 20"
SomeTextLen = Len(SomeText)
ActiveCell.Value = CurrentText & SomeText

With ActiveCell.Characters(Start:=CurrentTextLen + 1, Length:=SomeTextLen).Font
    .Size = 20
End With

For this, you need to know where your <> text starts (i.e. the length of the ActiveCell current contents, plus one)

You will also need the length of your <> text (i.e. the length of the <> text)

Upvotes: 1

Related Questions