我对 vba 编码很陌生。在工作表中,我试图通过检查同时列 J、K、O 中的条件来使用宏列(Q)添加一个附加列。因此,如果某些条件在每一列中传递,我希望在 Q 中输入一个值列对应的行。这是我放在一起的一段代码。
Option Explicit
Sub Button2_Click()
Sheet1.Activate
Dim i As Long
For i = 2 To .Cells(.Rows.Count, "B").End(xlUp).Row
'Check so that we only process non-empty cells
'(just in case there is an empty cell part-way through the data)
If Cells(i, 10).Value = "No" And Cells(i, 15) <= 0 Then
Cells(i, 17) = "Pending with employee"
Else
If Cells(i, 10).Value = "No" And Cells(i, 15) >= 0 And Cells(i, 11) = "No Action Pending" Then
Cells(i, 17) = "Pending with employee"
Else
If Cells(i, 10).Value = "No" And Cells(i, 15) >= 0 And Cells(i, 11) = "Pending With Manager" Then
Cells(i, 17) = "Pending with Manager"
Else
If Cells(i, 10).Value = "Yes" And Cells(i, 15) >= 0 And Cells(i, 11) = "No Action Pending" Then
Cells(i, 17) = "All Done"
'If Not IsEmpty(.Cells(i, "B").Value) Then
' If .Cells(i, "E").Value = "NA" Then'
'ThisWorkbook.Worksheets("CTCto TCC Conversion").Cells(i, "F").Value = "NA" '
End If
End If
End If
End If
Next i
End With
MsgBox "Column Created"
End Sub
它给我一个错误无效或不合格的参考。如果有任何错误需要纠正才能运行代码,请帮助我。
谢谢