-3
我想在同一個工作簿上運行循環,但它也沒有給我提供任何幫助。但是如果我直接在工作簿(CGDSOUSD)上運行這個VBA,它運行良好。所以我想知道如何讓VBA打開一個新文件後運行VBA。使用VBA打開一個Excel文件,並運行一個循環,但循環總是會被跳過
Dim rownumber As Integer
Dim colnumber As Integer
Dim total As Double
colnumber = 1
For colnumber = 1 To 23
If Cells(8, colnumber) = "DELTA" Then
total = 0
rownumber = 9
Do Until Cells(rownumber, colnumber) = "" And Cells(rownumber + 1, colnumber) = "" And Cells(rownumber + 5, 1) = ""
If Cells(rownumber, 1) = "" And (Cells(rownumber, 7).Value = "DSO TROPS" Or Cells(rownumber, 8).Value = "DSO TROPS" Or Cells(rownumber, 6).Value = "DSO TROPS") Then
total = total + (Cells(rownumber, colnumber).Value)
Else
End If
rownumber = rownumber + 1
Loop
Else
End If
colnumber = colnumber + 1
Next colnumber
total = Round(total, 2) 'will be imputed into E20 in risk tools
MsgBox total
安置自己的代碼作爲文本,而不是作爲一個圖像 –
你把這個代碼的加載事件......會發生什麼,如果你把一個斷點? – Hackerman
你是什麼意思「根本不會工作」。你的意思是它不會編譯?或者它只是跳過循環?或者它在循環內的一條線上崩潰?或者它不符合你的期望? – YowE3K