我是宏的新手,所以我想知道我在代碼中哪里出錯了。
我只想要一個簡單的 IF - AND 基于 2 個不同的列,結果應該在第三列
我的代碼是:
Sub FTL_Customer3()
Lastrow = Sheets("Raw data").Range("D" & Rows.Count).End(xlUp).Row
For i = 1 To Lastrow
If Sheets("Raw data").Cells(i, 5) = "Postponed to next month" And Sheets("Raw
data").Cells(i, 13) = "ATP Ship date after EOM" Then
Cells(i, 7).Value = "OK"
End If
Next I
End Sub
uj5u.com熱心網友回復:
確保您要測驗的單元格不包含錯誤:
Sub FTL_Customer3()
With Worksheets("Raw data")
Dim LastRow As Long
LastRow = .Range("D" & .Rows.Count).End(xlUp).Row
Dim i As Long
For i = 1 To LastRow
If Not IsError(.Cells(i, 5)) And Not IsError(.Cells(i, 13)) Then
If .Cells(i, 5) = "Postponed to next month" And _
.Cells(i, 13) = "ATP Ship date after EOM" Then
.Cells(i, 7).Value = "OK"
End If
End If
Next i
End With
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/364549.html
下一篇:PowerPoint中的VBA只能使用停止和F8步進,當它自己運行時,它會改變形狀1的填充顏色,但不會改變形狀2
