我编写了以下代码,只在我的excel的Sheet1中工作,现在我想把这段代码移到我的VBA的Module部分。请指教。
代码是这样的:
Private Sub ReviewCheck()
Dim i, val1, val2
For i = 1 To UsedRange.Rows.Count
val1 = UCase(Cells(i, "A").Value)
If ((InStr(val1, "ABC")) Or (InStr(val1, "XYZ")) Or (InStr(val1, "123"))) > 0 Then
If UCase(Cells(i, "B").Value) = "N" Then
'Cells(i, "C").Value = False
Cells(i, "A").Interior.ColorIndex = 3
ElseIf UCase(Cells(i, "B").Value) = "Y" Then
'Cells(i, "C").Value = True
Cells(i, "B").Interior.ColorIndex = xlNone
Else
'Cells(i, "C").Value = False
Cells(i, "B").Interior.ColorIndex = 6
End If
Else
Cells(i, "B").Interior.ColorIndex = xlNone
End If
Next i
End Sub
答案 0 :(得分:0)
右键单击左侧窗口并在VBE中选择“添加模块”,然后复制粘贴代码?确保删除Sheet1代码。