(1)单击“公式”—“定义名称”,输入名称“color”(名称须是唯一的,不能与已有名称相同)。引用位置处输入公式“=get.cell(63,sheet3!b3)”。 Get.cell()是宏表函数,用于获取单元格的某类信息。具体信息类型由数字指定,数字范围1~66。其中,63代表单元格背景颜色。 (2)在B11输入公式“=color”并右拉下拉获...
Try this one: Sub ColorMacro() Dim myCell As Variant For Each myCell In Range("A1:G10000") If myCell.Interior.Color = 10284031 Then myCell.Font.Bold = True myCell.Font.Italic = True With myCell.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 16777215 .TintAndShad...
Function按颜色计数(iAsRange, jAsRange)'新建一个自定义函数,函数名为 Countc(参数 1 是一个区域 i,参数 2 也是一个区域 j)Dim n As Integer '定义一个变量 n,变量 n 为数值Dim kAsRange'定义一个变量 k,变量 k 为区域For Each k In i '遍历区域 i 的所有单元格Ifk.Interior.Color = j.Interior....
.Color = RGB(255, 235, 156) End With With Application.ReplaceFormat .Interior.Color = RGB(255, 255, 255) With .Font .Color = RGB(255, 0, 0) .Bold = True .Italic = True End With End With Range("SearchRange").Replace What:="", Replacement:="", _ SearchFormat:=True, ReplaceFo...
Next icell End Function 2.根据颜色计数代码 Function CountColor(x As Range, ary2 As Range)Application.Volatile For Each i In ary2 If i.Interior.ColorIndex = x.Interior.ColorIndex Then CountColor = CountColor + 1 End If Next End Function 在这里我们定义了SumColor与CountColor两个自定义函数,SumC...
方法/步骤 1 打开一个工作样表作为例子。如图所示:2 输入cell函数公式,并使用color参数。如图所示:3 cell函数公式的参数必须使用双引号包括。如图所示:4 这里我们可以查看e33的单元格格式中的颜色格式为负值显示为红色,与正数的黑色颜色不同,所以得值为1,如图所示:5 将单元格负数颜色修改为黑色后,得值为0...
选中”7月3日“前面的单元格,插入-名称-定义-输入”color“-引用位置输入”=GET.CELL(38,B3)(这里的B3为“7月3日”单元格所在位置“)确认保存 A3=IF(COLOR=4,"返料","")颜色代码见下图:可
Function ConditionalColor(rg As Range, FormatType As String) As Long'Returns the color index (either font or interior) of the first cell in range rg. If no _conditional format conditions apply,Thenreturns the regular color of the cell. _ FormatTypeIseither "Font"Or"Interior" Dim cel As ...
FunctionfcountCol(colorAsRange,rngAsRange)DimcolorCellAsRangeApplication.VolatileForEachcolorCellInrngIfcolorCell.Font.ColorIndex=color.Font.ColorIndexThenfcountCol=1+fcountColEndIfNextEndFunction 查找单元格背景颜色自定义函数: FunctionfcountBGCol(colorAsRange,rngAsRange)Application.VolatileForEachiInrngIfi...
Choose your color scheme. For more options, click on Custom Format…. Repeat these steps for each emoji to apply different colors accordingly. IFS Function vs. Nested IF Statements Using the IFS function simplifies what could otherwise be a complex series of nested IF statements. ...