乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>ExcelVBA</em>中怎样得到当前使用的填充颜色值-excel vba 颜色填充,

<em>ExcelVBA</em>中怎样得到当前使用的填充颜色值-excel vba 颜色填充,

作者:乔山办公网日期:

返回目录:excel表格制作


如你的数据在A列,代码如下。
sub aa ()
for x =1 to range("A65536").end(xlup).row'建立循环
if cells(x,1)=6 then'判断单元格值
cells(x,1).interior.colorIndex = 3'单元格值等于6时,该单元格填充红
end if
next x
end sub

Sub s()
c = Array(33, 14, 47, 6, 7, 12)
n = Cells(Rows.Count, 11).End(3).Row
k = 0
Do While n > 1 And k < 20
cc = 0
For i = 11 To 52 Step 14
f1 = False
f2 = False
For j = 0 To 6
If Cells(n, i + j) = Cells(n - 1, i + j) Then f1 = True: Exit For
Next
For j = 7 To 13
If Cells(n, i + j) = Cells(n - 1, i + j) Then f2 = True: Exit For
Next
If f1 And f2 Then
For j = 0 To 13
If Cells(n, i + j) = Cells(n - 1, i + j) Then
Cells(n, i + j).Interior.ColorIndex = c(cc)
End If
Next
ElseIf f1 Then
For j = 0 To 6
If Cells(n, i + j) = Cells(n - 1, i + j) Then
Cells(n, i + j).Interior.ColorIndex = c(cc + 1)
End If
Next
ElseIf f2 Then
For j = 7 To 13
If Cells(n, i + j) = Cells(n - 1, i + j) Then
Cells(n, i + j).Interior.ColorIndex = c(cc + 1)
End If
Next
End If
cc = cc + 2
Next
n = n - 1
k = k + 1
Loop
End Sub
如你的数据在A列,代码如下。
sub aa ()
for x =1 to range("A65536").end(xlup).row'建立循环
if cells(x,1)=6 then'判断单元格值
cells(x,1).interior.colorIndex = 3'单元格值等于6时,该单元格填充红色
end if
next x
end sub

简单举例,假如A1单元格填充黄色 ,获得其值为6,代码如下

sub  Co

dim i as integer
i=[a1].interior.colorindex

end sub

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网