EXCEL VBA :有end if 卻沒有if?

2016-10-04 3:49 pm
Sub ro()
Dim ii, jj As Integer
Dim AA, TT As Object
Set AA = Workbooks("論文總檔.xlsx").Worksheets("總財務資料(目標)")
Set TT = Workbooks("目標財務資料.xlsm").Worksheets("工作表1")
For ii = 3 To 2000
AA.Select
Columns(B).Select
Set cusip = Cells.Find(What:=TT.Cells(ii, 6), LookIn:=xlFormulas).Activate
If cusip Is Nothing Then MsgBox "查無資料" Else
AA.Select
Range(Cells(1, 3), Cells(1, 40)).Select
Cells.Find(What:=TT.Cells(ii, 2), After:=ActiveCell, LookIn:=xlFormulas).Offset(1, 0) = TT.Cells(ii, 7)
End If
Next ii
End Sub

執行卻出現錯誤訊息: 有END IF 卻沒有 IF

請問該如何解決呢?

回答 (2)

2016-10-05 1:39 am
✔ 最佳答案
If cusip Is Nothing Then
MsgBox "查無資料"
Else
AA.Select
Range(Cells(1, 3), Cells(1, 40)).Select
Cells.Find(What:=TT.Cells(ii, 2), After:=ActiveCell, LookIn:=xlFormulas).Offset(1, 0) = TT.Cells(ii, 7)
End If
2016-10-05 12:25 am
IF ..... THEN
.....
ELSE
....
IF


收錄日期: 2021-05-03 13:49:14
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20161004074943AAzdTzA

檢視 Wayback Machine 備份