Get Cell Color Function Function returns the active cell interior or font color index, regardless of whether it was set by regular or Conditional Formatting.
Sub GetCellColor() Dim ws As Worksheet Dim cell As Range Dim colorValue As Long ' 设置工作表和单元格 Set ws = ThisWorkbook.Sheets("Sheet1") ' 替换为你的工作表名称 Set cell = ws.Range("A1") ' 替换为你想要获取颜色的单元格 ' 获取单元格颜色值 colorValue = cell.Interior.Color ' 输出...
If you're trying toretrieve the colors of a cell in a traditional way, you'll only get the cell's default colors, ignoring any conditional formatting. To retrieve the displayed color (taking into account conditional formatting), simply addDisplayFormatto your code. ...
不一定用vba,用get.cell函数再配合自定义名称;当然vba更简单。只要定义一个2维数组,把颜色编号和对应的英文名字全纳入到数组里,这样用colorIndex取颜色编号,就能获得该编号对应颜色的英文名。有名称的颜色名一共56种。
GetBulge 获取多段线上给定索引位置的凸度值。 GetCanonicalMediaNames 获取指定打印设备的所有可用规范介质的名称。 GetCellAlignment 返回指定行和列的单元格的对齐方式。(2005新增) GetCellBackgroundColor 返回指定行和列的单元格的背景真彩色值。(2005新增) GetCellBackgroundColorNone 返回指定的行和列是否无背景...
Function GetColourSum(MyRange As Range, Optional FontOrBG As Boolean) As Double Dim MyColour As Long MyColour = Application.ThisCell.Interior.Color Dim MyCell As Range If IsMissing(FontOrBG) Then FontOrBG = False For Each MyCell In MyRange ...
(1)单击“公式”—“定义名称”,输入名称“color”(名称须是唯一的,不能与已有名称相同)。引用位置处输入公式“=get.cell(63,sheet3!b3)”。 Get.cell()是宏表函数,用于获取单元格的某类信息。具体信息类型由数字指定,数字范围1~66。其中,63代表单元格背景颜色。
Excel的VBA中,无颜色的是rgb(255,255,255)吧?如果要统计有颜色填充个数的,判断不等于这个颜色的就可以了。也建议用宏表函数get.cell 用手机看你的代码太乱,没法修改。其实很简单,做个循环,判断选区中的每个单元格的填充颜色是否等于这个rgb的颜色就行了。不等于就是有颜色,就统计上。
currCell.Value = "RGB(" & r & ", " & g & "," & b & ")" currCell.Interior.color = RGB(r, g, b) If GetContrastColor(currCell.Interior.color) = vbBlack Then currCell.Font.color = vbBlack Else currCell.Font.color = vbWhite ...
' However, this is the place to capture the cell's address or reference, ' and its about-to-be-changed color.] Call CallByName(objSheet, "CaptureCurrentStuff", VbMethod, ActiveCell) '--- Highlight that cell in green. [You can replace vbGreen with the ' RGB function...