代码语言:vba 复制 Sub CheckConditionalFormatting() If ActiveCell.Interior.ColorIndex = -4142 Then ' 条件格式错误处理代码 MsgBox "条件格式错误!" Else ' 条件格式正确处理代码 MsgBox "条件格式正确!" End If End Sub 在这个示例中,我们使用了If语句来检查ActiveCell的背景颜色是否为-4142。如果是-4142,...
问VBA - ActiveCell.Interior.ColorIndex -4142条件格式错误EN内置的图标无法缩小(截止2022年9月),自...
With ws1 lastrow2 = ws1.Range("A" & Rows.Count).End(xlUp).Row For i = lastrow2 To 2 Step -1 nodel = False If .Cells(i, "D").Interior.ColorIndex = 2 Then nodel = True End If If .Cells(i, "D").Interior.ColorIndex = -4142 Then nodel = True End If If Not nodel ...
2. 通过ColorIndex属性修改单元格字体的颜色 通过上面的方法外,还可以通过指定Range.Font.ColorIndex属性来修改单元格字体的颜色,该属性表示了调色板中颜色的索引值,也可以指定一个常量,xlColorIndexAutomatic(-4105)为自动配色,xlColorIndexNone(-4142)表示无色。 3. 一个Format单元格的例子 Subcmd() Cells(1,"D...
1、把数据读入数组,我还是习惯用数组,其实本案可以直接操作单元格,比数组方便。2、数组为n行3列的数组,通过循环把第二列清空,准备填写取号结果,第三列存入第一列对应单元格的颜色值。3、计数器变量t=2,每生成一个号段加上1,顺序写入数组的第二列。4、通过判断第三列颜色值,是否是无颜色(-4142),...
Sub count_color()Dim j As IntegerDim n As IntegerDim i As IntegerFor j = 1 To 4i = 1 '重置i,每次统计新颜色,重置i也就是A列的行号n = 0 '每次统计新颜色,重置n'循环A列,当循环到单元格没有颜色填充就退出循环Do Until Cells(i, 1).Interior.ColorIndex = -4142'如果颜色一样,就累计If ...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)On Error Resume NextApplication.ScreenUpdating = FalseCells.Interior.ColorIndex = -4142 '取消原色Rows(Target.Row).Interior.ColorIndex = 17 '整行着色Columns(Target.Column).Interior.ColorIndex = 17 '整列着色Range("A1:W1").Interior.ColorIn...
(lastRow, 3) = -4142 Then arrData(t, 2) = arrData(i, 1) & "--" & arrData(i, 1) Else arrData(t, 2) = arrData(m, 1) & "--" & arrData(lastRow, 1) End If ws.Range("B2:B" & lastRow).NumberFormat = "@" ws.Range("A1").Resize(lastRow - 1, 2) = arrData ...
Range['A1:H150'].Interior.Pattern = xlNone '常量值: -4142排序' 排序 Selection.Sort Key1:=Range("B9"), Order1:=xlAscending,Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _ :=xlPinYin ' 区域内排序 Range("A3:G13").Select Selection.Sort ...
445113337414755481034354250515214491339 无色-4142自动-4105黑色1白色2红色3鲜绿4蓝色5黄色6粉红7青绿8深红9绿色10深蓝11深黄12紫罗兰13青色14灰色2515灰色5016天蓝33浅青绿34浅绿35 浅黄淡蓝玫瑰红淡紫茶色浅蓝水绿色酸橙色金色浅橙色橙色蓝灰灰色40深青海绿深绿橄榄褐色梅红靛蓝灰色80 363738394041424344454647484950515253545556 ...