繁体   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