|
请老师帮忙看下,以下是条件赋值,但是为什么只能给第一个if给值,后面的都不变,请帮忙看下,或者有更好的写法,谢谢!
Dim i As Long
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("2024Raw Data")
For i = 1 To 10000
If ws.Cells(i, 4).Value = Sheet4.Range("g185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("g8").Value
If ws.Cells(i, 4).Value = Sheet4.Range("h185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("h8").Value
If ws.Cells(i, 4).Value = Sheet4.Range("i185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("i8").Value
If ws.Cells(i, 4).Value = Sheet4.Range("j185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("j8").Value
If ws.Cells(i, 4).Value = Sheet4.Range("k185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("k8").Value
If ws.Cells(i, 4).Value = Sheet4.Range("l185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("l8").Value
If ws.Cells(i, 4).Value = Sheet4.Range("m185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("m8").Value
If ws.Cells(i, 4).Value = Sheet4.Range("n185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("n8").Value
If ws.Cells(i, 4).Value = Sheet4.Range("o185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("o8").Value
If ws.Cells(i, 4).Value = Sheet4.Range("p185").Value And ws.Cells(i, 7).Value = Sheet4.Range("C1").Value Then
ws.Cells(i, 12).Value = Sheet4.Range("p8").Value
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Next i
END SUB
|
|