Public Function ColorChange()For i = 2 To Cells(1000, 2).End(xlUp).RowIf Cells(i, 2).Interior.Color = 12611584 ThenColorChange = "配料"Exit FunctionEnd IfNextColorChange = ""End Function判断单元格的颜色,现在只能使用vba呢。函数不能判断单元格的颜色。用IF 判断啊
51CTO博客已为您找到关于excel if函数变颜色的相关内容,包含IT学习相关文档代码介绍、相关教程视频课程,以及excel if函数变颜色问答内容。更多excel if函数变颜色相关解答可以来51CTO博客参与分享和学习,帮助广大IT技术人实现成长和进步。
编写按颜色求和的代码:在模块1输入如下代码:Function YS(颜色 As Range, 区域 As Range)Dim x As Range s = 颜色.Interior.Color For Each x In 区域 If x.Interior.Color = s Then n = n + x.Value End If Next YS = n End Function 2.1输入自定义公式:在C10单元格输入刚刚的自定义公式“=YS...
If rng.Interior.ColorIndex = col.Interior.ColorIndex Then SumColor = Application.Sum(rng) + SumColor End If Next rng End Function 这样的话,我们单元格里面输入公式:=SumColor(B2:D14,B3)我们用代码自定义了一个求和函数,第一个参数是求和区域,第二个参数是求和的颜色参照单元格 VBA代码的方法,当...
Function SumColor(sum_range As Range, ref_rang As Range) Dim x As Range For Each x In sum_range If x.Interior.ColorIndex = ref_rang.Interior.ColorIndex Then SumColor = Application.Sum(x) + SumColor End If Next x End Function
EachRgIn求和区域SelectCase颜色类型Case"填充"Bol = (Rg.Interior.Color = 参考单元格.Interior.Color)Case"字体"Bol = (Rg.Font.Color = 参考单元格.Font.Color)CaseElse按颜色求和 ="第三参数出错,请检查确认"ExitFunctionEndSelectIfBolThenTotal = Total + Rg.ValueEndIfNext按颜色求和 = TotalEndFunction...
.Color = -16776961 .TintAndShade = 0 End With End If Next myCell End Sub The color value of your RGB values = 10284031 (i.e. the result of R+G*256+B*256*256). You need this to be able to read out color value in each of your cells....
EachRgIn求和区域SelectCase颜色类型Case"填充"Bol = (Rg.Interior.Color = 参考单元格.Interior.Color)Case"字体"Bol = (Rg.Font.Color = 参考单元格.Font.Color)CaseElse按颜色求和 ="第三参数出错,请检查确认"ExitFunctionEndSelectIfBolThenTotal = Total + Rg.ValueEndIfNext按颜色求和 = TotalEndFunction...
If x.Interior.ColorIndex = ref_rang.Interior.ColorIndex Then SumColor = Application.Sum(x) + SumColor End If Next x End Function (3)返回工作表即可用函数SUMCOLOR进行求和了。 附上代码解析: 注意:使用了宏表函数,以及VBA自定义函数后,文件需要保存为支持宏的xlsm格式。 小结 1.如果是利用条件格式赋予...
{"__typename":"ForumTopicMessage","uid":1147123,"subject":"Excel Macros If Function Based on Cell Color","id":"message:1147123","revisionNum":1,"repliesCount":4,"author":{"__ref":"User:user:542405"},"depth":0,"hasGivenKudo":false,"board":{"__ref":"Forum:board:ExcelGeneral"},...