vba Excel vba将字符串的粗体特定文本设置到单元格中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11644566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel vba set bold specific text of string into the cell?
提问by Mennan
I want to set bold some text in string.How can i do it ?
我想在字符串中加粗一些文本。我该怎么做?
回答by GSerg
By using Characters.
通过使用字符。
Range("A1").Characters(8, 5).Font.Bold = True
回答by anish
I would say use this dynamic formula -
我会说使用这个动态公式 -
Range("A1").Characters(worksheetfunction.find("Excel",Range("A1").value,1),len("Excel")).font.bold = True
回答by ChaPPer5
Another way for people who need a quick fix and aren't comfortable using VBA:
对于需要快速修复并且不习惯使用 VBA 的人的另一种方法:
- Copy and paste the cell range into a word document (it will look messy at first).
- Go to "replace" (top right).
- Type the word you want to make bold into the "Find what:" field and the same into the "Replace with:" field, then when you are on the "Replace With:" box press CTRL B. You should see "Format: Font: Bold" appear beneath it.
- Click Replace All and you should see all the targeted words go bold.
- Hover over your Excel text (currently in Word) and you should see a small symbol of 4 arrows appear at the top left of the text. Click that to highlight the cells, then you can copy them and paste back into excel.
- 将单元格范围复制并粘贴到 Word 文档中(一开始会看起来很乱)。
- 转到“替换”(右上角)。
- 在“查找内容:”字段中输入要加粗的单词,在“替换为:”字段中输入相同内容,然后在“替换为:”框中按 CTRL B。您应该看到“格式:字体:粗体”出现在其下方。
- 单击全部替换,您应该会看到所有目标词都变为粗体。
- 将鼠标悬停在 Excel 文本(当前在 Word 中)上,您应该会看到文本左上角出现一个由 4 个箭头组成的小符号。单击它以突出显示单元格,然后您可以复制它们并粘贴回 Excel。
Not the fastest way but if you're not familiar with VBA and need a quick fix this will work for you!
不是最快的方法,但如果您不熟悉 VBA 并且需要快速修复,这对您有用!
Not just for Bold: CTRL I for italics, CTRL U for underlined.
不仅仅是粗体:CTRL I 表示斜体,CTRL U 表示下划线。