-1
不考慮條件,則在下面的代碼被忽略時,不會考慮2個最後的條件。你能幫助理解爲什麼嗎? 此外,「r」範圍檢索預期結果+1行。我沒有設法改變這一點。有任何想法嗎?如果使用excel VBA
Dim x As Range
Dim r As Range
Dim j As Range
Set r = Range("J2").End(xlDown)
Set j = Range("D2").End(xlDown)
For Each x In Range("J2", r)
If x.Value < 0 And j = ("long") Or j = ("") Then
x.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=R[-1]C+RC[-1]"
End If
Next
End Sub
你可能是對的問題是什麼更具體的?我不認爲你可以設置這樣的範圍(雖然不知道)。 – 2014-09-29 09:22:32
問題是隻有第一個條件工作「如果x.Value <0」,「j =(」long「)或j =(」「)」沒有被考慮。我也嘗試過「j.value」,J.cells,但它確實有效。 – 2014-09-29 09:43:01
也許'if(x.Value <0)和(j =(「long」)或j =(「」))??或者請記住運營商的執行順序 – 2014-09-29 09:55:44