Excel用公式判断有颜色的单元格

如何用公式判断“J列”或“M列”的单元格哪个有标记黄色,在“P列”显示出有颜色单元格的数据。例:J124是黄色,M124没有颜色,则P124填入9613900000.

用自定义函数,需要辅助列
或直接用代码完成
Sub 提取颜色()
Columns("P") = ""
Dim I%
For I = 2 To Range("J65536").End(xlUp).Row
If Cells(I, "J").Interior.ColorIndex = 6 Then
Cells(I, "P") = Cells(I, "J")
End If
If Cells(I, "M").Interior.ColorIndex = 6 Then
Cells(I, "P") = Cells(I, "M")
End If
Next
End Sub
温馨提示:答案为网友推荐,仅供参考