查找单元格字符串中数字部分,并标注红色 (原创)

来源:互联网 发布:淘宝小石头运动 证吗 编辑:程序博客网 时间:2024/05/18 02:31
Sub ChangeColor()'======================================='查找单元格字符串中数字部分,并标注颜色'型号中一般缸径、行程均为数字表示,有助于观看。'作者:xiaohe'========================================    Dim strNum() As String    Dim i As Integer    Dim strContent As String        strContent = ActiveCell        i = Len(strContent)        ReDim strNum(i)        For ii = 0 To i            strNum(ii) = Right(Left(strContent, ii), 1)            Next ii             For j = LBound(strNum) To UBound(strNum) - 1               If Asc(strNum(j + 1)) >= 48 And Asc(strNum(j + 1)) <= 57 Then                        With ActiveCell.Characters(Start:=j + 1, Length:=1).Font                            .ColorIndex = 3                                End With                    End If            Next j    End Sub


	
				
		
原创粉丝点击