|
如题,1、我想要字体加粗的时候才计数,标注颜色,但是现在都是出现了的都计数标注颜色了,标注颜色的没错的,就是不能字体加粗才计数的,
2、B2到U16不加粗的显示RGB(112, 128, 144),加粗的显示黑色
3、B17到U20都是不加粗的,显示黑色
怎么调都调不出来 酬谢!!!
Sub 更新数据()
[b2:u20].Interior.Color = xlNone
Range("b2:u20").Font.Color = RGB(112, 128, 144)
[c2:u20].Copy [b2]
[ac2:ac20].Copy [u2]
rw = Sheets("行业历史数据").[a65536].End(xlUp).Row + 1
[ad2:ad20].Copy
Sheets("行业历史数据").[a65536].End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
[ac2:ac20].ClearContents
With Sheets("行业历史数据")
.Cells.Interior.Color = xlNone
.Range(.Cells(rw, 2), .Cells(rw + 14, 2)) = VBA.Now
End With
更新颜色
更新一日游
End Sub
Sub 更新颜色()
Dim irng As Range, arr, brr()
Set irng = [b2:u20]
irng.Interior.Color = xlNone
irng.Font.Color = RGB(112, 128, 144)
js = Range("z1:z" & [z65536].End(xlUp).Row)
Set d = CreateObject("scripting.dictionary")
Set e = CreateObject("scripting.dictionary")
Set r = CreateObject("vbscript.regexp")
arr = irng.Value
For i = 1 To UBound(arr)
For j = 1 To UBound(arr, 2)
k = arr(i, j)
With r
.Pattern = "[\d\-\.]+"
.Global = True
arr(i, j) = .Replace(k, "")
End With
If irng.Cells(i, j).Font.Bold = True Then
d(arr(i, j)) = d(arr(i, j)) + 1
e(arr(i, j)) = e(arr(i, j)) + 1
Next
Next
For Each k In e.keys
If Not d.exists(k) Then
If e(k) > 1 Then
d(k) = 1
Else
d(k) = 0.5
End If
End If
Next
On Error Resume Next
If js <> "" Then
For Each k In js
k = r.Replace(k, "")
If d.exists(k) Then
If d(k) = 0.5 Then
d(k) = 0
Else
d(k) = d(k) - 1
End If
End If
Next
End If
ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
For i = 1 To UBound(arr)
For j = 1 To UBound(arr, 2)
brr(i, j) = d(arr(i, j))
If arr(i, j) <> "" Then fillcolor irng.Cells(i, j), brr(i, j)
Next
Next
End Sub
|
|