简体   繁体   English

如何在Microsoft Excel VBA中使用修改后的字体选项向现有单元格添加其他文本

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

For example Microsoft VBA: 例如,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 您想要更改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

For this, you need to know where your <> text starts (ie the length of the ActiveCell current contents, plus one) 为此,您需要知道<>文本的起始位置(即ActiveCell当前内容的长度加一)。

You will also need the length of your <> text (ie the length of the <> text) 您还需要<>文本的长度(即<>文本的长度)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Microsoft Excel VBA中的合并单元格中修改(更改为粗体)特定文本字符串? - How can I modify (change to bold) a specific string of text in a merged cell in Microsoft Excel VBA? excel或excel VBA:如何让用户单击某个单元格并将其用作与现有单元格的匹配结果 - excel or excel VBA: how can I let user click on a cell and use it as a match result to an existing cell 如何将输入文本作为日期传输到 VBA 中的 Excel 单元格 - How can I transfer an input text as a date to an Excel cell in VBA 如何在Microsoft Excel中将一个单元格中的文本作为另一个单元格中的公式计算? - How can I calculate the text in one cell as a formula in another cell in microsoft excel? 如何在Microsoft Excel中使用公式添加左单元格和上单元格? - how can I add the left cell and the upper cell using a formula in microsoft excel? Excel VBA。 在现有单元格中添加1年 - Excel VBA. Add 1 year to existing cell 如何将单元格的文本添加到Excel公式中? - How can I add a cell's text into an excel formula? Excel VBA:如何将文本添加到特定列中的空白单元格,然后循环到下一个空白单元格并添加文本? - Excel VBA: How do I add text to a blank cell in a specific column then loop to the next blank cell and add text? 如何将数据添加到现有 excel.csv 文件的行中? excel vba - how can i add data to rows of an existing excel.csv file? excel vba 修改了excel单元格中的文本? - Modified the text in excel cell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM