- 帖子
- 438
- 主題
- 67
- 精華
- 0
- 積分
- 531
- 點名
- 0
- 作業系統
- win7
- 軟體版本
- office 2010
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2012-10-30
- 最後登錄
- 2024-11-19
|
43#
發表於 2012-12-14 14:42
| 只看該作者
本帖最後由 GBKEE 於 2012-12-14 14:57 編輯
回復 41# GBKEE - Option Explicit
- Sub ex()
- Dim FRng As Range, Wb As Workbook
- Dim A As Range, Rng As Range
- Dim fs As String, xi As Integer
- Dim i As Integer
- Dim j As Integer
- Dim k As Integer
- i = Worksheets("outstanding payments").Range("A" & Worksheets("outstanding payments").Rows.Count).End(xlUp).Row
- fs = "C:\Users\patrick.HKG\Desktop\payment report 2012.xlsx"
- Set Wb = Workbooks.Open(fs)
- With Worksheets("New form of payment report")
- j = Worksheets("New form of payment report").Range("E" & Worksheets("New form of payment report").Rows.Count).End(xlUp).Row
- End With
- Do
- ThisWorkbook.Activate
- If Wb.Worksheets("New form of payment report").Range("k" & j).Value = Date And Wb.Worksheets("New form of payment report").Range("h" & j).Value >= 0.95 Then
- If IsError(Application.VLookup(Wb.Worksheets("New form of payment report").Range("B" & j).Value, Worksheets("outstanding payments").Range("A:A"), 1, False)) Then
- Worksheets("outstanding payments").Range("A" & i + 1) = Wb.Worksheets("New form of payment report").Range("B" & j).Value
- Worksheets("outstanding payments").Range("F" & i + 1) = Wb.Worksheets("New form of payment report").Range("K" & j).Value
- End If
- i = i + 1
- End If
- j = j - 1
- Loop While j = 2
-
- Wb.Close 0
- End Sub
複製代碼 請問
Do
Loop While
是不是寫錯了?他不懂得循環做 |
|