|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码如下,,,
Sub FormatCell()
Dim color As Long
Dim target As String
Dim source As Range
Dim current As Range
Set source = Range("A1:A30")
target = ":"
color = -16776961
For Each current In source
With current.Font
.ColorIndex = 1
.Bold = False
End With
Start = 0
s = current.Value
x = Len(s) - Len(Replace(s, Chr(10), ""))
For i = 1 To x + 1
If Start = 0 Then
ret = 1
Else
ret = InStr(ret, current.Value, Chr(10)) + 1
End If
ret1 = InStr(ret, current.Value, Chr(10))
Start = InStr(ret, current.Text, target) '+ 1
If ret = 0 Or Start = 0 Then Exit For
If ret1 < Start And ret1 <> 0 Then ret = InStr(ret, current.Value, Chr(10)) + 1
Length = Len(current.Text) - InStr(1, current.Text, target)
With current.Characters(Start:=ret, Length:=Start - ret + 1).Font
.color = color
.Bold = True
End With
Next
Next
Beep
End Sub
|
评分
-
2
查看全部评分
-
|