[英]Excel vba set bold specific text of string into the cell?
我想在字符串中加粗一些文本。我该怎么做?
通过使用字符。
Range("A1").Characters(8, 5).Font.Bold = True
我会说使用这个动态公式 -
Range("A1").Characters(worksheetfunction.find("Excel",Range("A1").value,1),len("Excel")).font.bold = True
Another way for people who need a quick fix and aren't comfortable using VBA:对于需要快速修复并且不习惯使用 VBA 的人的另一种方法:
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 表示下划线。
Try this if you need to bold multiple specific text:如果您需要加粗多个特定文本,请尝试此操作:
Sub Find_and_Bold()
Dim rCell As Range, sToFind As String, iSeek As Long
Dim Text(1 To 4) As String
Dim i As Integer
Text(1) = "text1"
Text(2) = "text2"
Text(3) = "text3"
Text(4) = "text4"
For Each rCell In Range("C7:C1000")
For i = LBound(Text) To UBound(Text)
sToFind = Text(i)
iSeek = InStr(1, rCell.Value, sToFind)
Do While iSeek > 0
rCell.Characters(iSeek, Len(sToFind)).Font.Bold = True
iSeek = InStr(iSeek + 1, rCell.Value, sToFind)
Loop
Next i
Next rCell
End Sub
The source for this solution is from: http://www.vbaexpress.com/forum/showthread.php?52245-Make-specific-text-bold-in-cells此解决方案的来源来自: http : //www.vbaexpress.com/forum/showthread.php?52245-Make-specific-text-bold-in-cells
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.