此代码在假设时不会打印-1
和0
,
但其他一切都很好。
它遍历两个列表:(Sheet1
和edi_partnere
)
当它被假定时退出循环。
问:我错过了什么:为什么没有cells().value
抓住?
Do
If orgnr1 = "" Then Exit Sub
Do
orgnr2 = Sheets("edi_partnere").Cells(j, 1).Value
If orgnr2 = orgnr1 Then
Sheets("Sheet1").Cells(j, 9).Value = "-1" 'not happening
Exit Do
ElseIf orgnr2 = "" Then
Sheets("Sheet1").Cells(j, 9).Value = "0" 'not happening
Exit Do
Else: j = j + 1
End If
Loop
i = i + 1
orgnr1 = Sheets("Sheet1").Cells(i, 1).Value
Loop
答案 0 :(得分:0)
我认为你必须重置变量j,所以我在代码中添加j = 0。
根据Siddharth Rout,如果没有设置orgnr1那么orgnr1 = Sheets(" Sheet1")。Cells(i,1).Value
Do
If orgnr1 = "" Then Exit Sub
Do
orgnr2 = Sheets("edi_partnere").Cells(j, 1).Value
If orgnr2 = orgnr1 Then
Sheets("Sheet1").Cells(j, 9).Value = "-1" 'not happening
Exit Do
ElseIf orgnr2 = "" Then
Sheets("Sheet1").Cells(j, 9).Value = "0" 'not happening
Exit Do
Else: j = j + 1
End If
Loop
j = 0
i = i + 1
orgnr1 = Sheets("Sheet1").Cells(i, 1).Value
Loop