写了一个过程,从1行1列开始寻找,寻找到黄色的就记录下来放到mystr中,最后显示出来。
Sub abc()
Dim i, j As Integer
Dim mystr As String
i = 1
j = 1
While i < 50
While j < 100
If Sheet1.Cells(i, j).Interior.ColorIndex = 6 Then
mystr = mystr + "行=" + Str(i) + ",列=" + Str(j) + Chr(13) ‘记录黄色单元格的行和列
End If
j = j + 1
Wend
i = i + 1
j = 1
Wend
MsgBox mystr
End Sub