简体   繁体   中英

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

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 (ie the length of the ActiveCell current contents, plus one)

You will also need the length of your <> text (ie the length of the <> text)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM