簡體   English   中英

如何在Microsoft Excel VBA中使用修改后的字體選項向現有單元格添加其他文本

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

例如,Microsoft VBA:

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

我如何在“ <>”括號內實現該描述

您想要更改ActiveCell.Characters()。Font屬性

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

為此,您需要知道<>文本的起始位置(即ActiveCell當前內容的長度加一)。

您還需要<>文本的長度(即<>文本的長度)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM