将填充颜色放在特定的单元格中

我的程序循环遍历表单中的每一行数据。 然后,当它错误,我想填充颜色在特定的单元格。

有没有一种方法来填充颜色的单元格而不使用范围?

On Error GoTo Stop 'doing something Exit Sub Stop: Msgbox("Error!") 'something like this to fill the cell Sheets("Data").Cells(rowdata,1).Color = red 

你可以这样做

 Cells(rowindex, columnindex).interior.color = RGB-code cells(rowindex, columnindex).interior.colorindex = indexno