我正在尝试创建一个Do While循环,其中嵌入了一个if语句。根据if语句的TRUE/FALSE值,它可以进入另一个(子)Do While环路,也可以循环回第一个,然后重新开始。
我的问题是,一旦If语句返回"TRUE"值,宏就会执行结果,但随后会停止我要继续的第一个覆盖的Do While循环。(基本上,一旦If语句中有TRUE值,它就不会为x+1生成另一个循环)
提前感谢您对的帮助
'x is row in input tab
Dim x As Integer
'z is column in input tab
Dim z As Integer
x = 9
Do While x < 59
If Sheets("Input Tool (Auction Team)").Cells(x, "C") = "N" And Cells(x, "D") = "Yes" Then
'insert row and add values
Sheets("Round Results (Auction Team)").Range("C13").EntireRow.Insert
z = 5
Do While z < 19
Sheets("Input Tool (Auction Team)").Cells(x, z).Copy
Sheets("Round Results (Auction Team)").Cells(13, z - 2).PasteSpecial Paste:=xlPasteValues
Sheets("Round Results (Auction Team)").Cells(14, z - 2).Copy
Sheets("Round Results (Auction Team)").Cells(13, z - 2).PasteSpecial Paste:=xlPasteFormats
Sheets("Round Results (Auction Team)").Cells(14, 2).Copy Cells(13, 2)
z = z + 1
Loop
Else
End If
x = x + 1
Loop
End Sub
用它们的父对象限定不合格的对象引用。
例如,我看到"单元格(x,"D")"。将该范围限定为父工作表,如下所示:
Sheets("Input Tool (Auction Team)").Cells(x,"D")