我尝试在列“L”和列“V”两者都表示“已完成”时运行代码。然后列“W”将显示“已完成”,否则它将显示“未完成”,但它显示编译错误“Else withou if”。
以下是我的代码
Sub OverallStatus()
Dim x As Long
Dim lastrow As Long
With Sheet1
If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
lastrow = .Cells.Find(What:="*", _
After:=.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Else
lastrow = 1
End If
For x = 2 To lastrow
If .Range("L" & x) = "Completed" And .Range("V" & x) = "Completed" Then
.Range("W" & x) = "Completed"
Else: .Range("W" & x) = "Incomplete"
End If
Next
End With
End Sub
答案 0 :(得分:0)
您的代码需要更改的内容:
Then
之后If
End If
Next
End If
End Sub
上方的End With
醇>