Excel vba将粗体特定的字符串文本设置到单元格中?

时间:2022-07-25 22:18:19

I want to set bold some text in string.How can i do it ?

我想在字符串中设置粗体。我怎么做呢?

3 个解决方案

#1


22  

By using Characters.

通过使用字符。

Range("A1").Characters(8, 5).Font.Bold = True

#2


5  

I would say use this dynamic formula -

用这个动态公式

Range("A1").Characters(worksheetfunction.find("Excel",Range("A1").value,1),len("Excel")).font.bold = True

#3


1  

Another way for people who need a quick fix and aren't comfortable using VBA:

对于那些需要快速修复并且不喜欢使用VBA的人来说,另一种方法是:

  1. Copy and paste the cell range into a word document (it will look messy at first).
  2. 将单元格范围复制并粘贴到word文档中(首先看起来会很混乱)。
  3. Go to "replace" (top right).
  4. 去“替换”(右上角)。
  5. 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.
  6. 在“查找什么:”字段中键入要加粗的单词,在“替换为:”字段中输入相同的单词,然后当您在“替换为:”框中按CTRL b时,您将看到“Format: Font: bold”出现在该字段下面。
  7. Click Replace All and you should see all the targeted words go bold.
  8. 单击Replace All,您应该看到所有的目标字都是粗体的。
  9. 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.
  10. 将鼠标悬停在您的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加下划线。

#1


22  

By using Characters.

通过使用字符。

Range("A1").Characters(8, 5).Font.Bold = True

#2


5  

I would say use this dynamic formula -

用这个动态公式

Range("A1").Characters(worksheetfunction.find("Excel",Range("A1").value,1),len("Excel")).font.bold = True

#3


1  

Another way for people who need a quick fix and aren't comfortable using VBA:

对于那些需要快速修复并且不喜欢使用VBA的人来说,另一种方法是:

  1. Copy and paste the cell range into a word document (it will look messy at first).
  2. 将单元格范围复制并粘贴到word文档中(首先看起来会很混乱)。
  3. Go to "replace" (top right).
  4. 去“替换”(右上角)。
  5. 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.
  6. 在“查找什么:”字段中键入要加粗的单词,在“替换为:”字段中输入相同的单词,然后当您在“替换为:”框中按CTRL b时,您将看到“Format: Font: bold”出现在该字段下面。
  7. Click Replace All and you should see all the targeted words go bold.
  8. 单击Replace All,您应该看到所有的目标字都是粗体的。
  9. 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.
  10. 将鼠标悬停在您的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加下划线。