Board logo

標題: [發問] 執行階段錯誤-形態不符合-問題請教 [打印本頁]

作者: rouber590324    時間: 2015-9-17 14:20     標題: 執行階段錯誤-形態不符合-問題請教

dear  all 大大
1執行圖一程式停於
  Sheet60.Cells(M, 53) = "C4  " & mymax2
  秀出執行階段錯誤-形態不符合
2請叫何原因-煩不吝賜教  thanks*10000

圖一
Sub BADR函數VBA化1()
'BA-DR函數VBA化
Sheet60.[BA2:BC65536].ClearContents
X = Sheet60.[T65536].End(xlUp).Row
For M = 2 To X
Z = Sheet60.Cells(M, 15) & Sheet60.Cells(M, 21) & Round(Sheet60.Cells(M, 18) * Sheet60.Cells(1, 27) + Sheet60.Cells(1, 17), 1) & "+" & Round(Sheet60.Cells(M, 19) * Sheet60.Cells(1, 27) + Sheet60.Cells(1, 17), 1)
mymax2 = Evaluate("VLOOKUP(""" & Z & """,Symbol Pin Report!B:J,3,FALSE)")
If Sheet60.Cells(M, 20) = "A01" Then
Sheet60.Cells(M, 53) = "C4  " & mymax2
End If
If Sheet60.Cells(M, 20) = Sheet60.Cells(1, 26) Then
Sheet60.Cells(M, 53) = "BGA  " & mymax2
Else
Sheet60.Cells(M, 53) = "??" & mymax2
End If
'=IF(T2="A01","C4  ",IF(T2=$Z$1,"BGA  ","??"))&VLOOKUP(O2&U2&ROUND(R2*$AA$1+$Q$1,1)&"+"&ROUND(S2*$AA$1+$Q$1,1),'Symbol Pin Report'!B:J,3,FALSE)
'=IF(T2="A01","C4  ",IF(T2=$Z$1,"BGA  ","??"))&VLOOKUP(O2&U2&ROUND(R2*$AA$1+$Q$1,1)&"+"&ROUND(S2*$AA$1,1),'Symbol Pin Report'!B:J,3,FALSE)
B = Sheet60.Cells(M, 15) & Sheet60.Cells(M, 21) & Round(Sheet60.Cells(M, 18) * Sheet60.Cells(1, 27) + Sheet60.Cells(1, 17), 1) & "+" & Round(Sheet60.Cells(M, 19) * Sheet60.Cells(1, 27) + Sheet60.Cells(1, 17), 1)
mymax3 = Evaluate("VLOOKUP(""" & B & """,Symbol Pin Report!B:J,7,FALSE)")
Sheet60.Cells(M, 54) = Round(mymax3 / 1000, 3)
'=ROUND(VLOOKUP(O2&U2&ROUND(R2*$AA$1+$Q$1,1)&"+"&ROUND(S2*$AA$1+$Q$1,1),'Symbol Pin Report'!B:J,7,FALSE)/1000,3)
'=ROUND(VLOOKUP(O2&U2&ROUND(R2*$AA$1+$Q$1,1)&"+"&ROUND(S2*$AA$1,1),'Symbol Pin Report'!B:J,7,FALSE)/1000,3)
C = Sheet60.Cells(M, 15) & Sheet60.Cells(M, 21) & Round(Sheet60.Cells(M, 18) * Sheet60.Cells(1, 27) + Sheet60.Cells(1, 17), 1) & "+" & Round(Sheet60.Cells(M, 19) * Sheet60.Cells(1, 27) + Sheet60.Cells(1, 17), 1)
mymax4 = Evaluate("VLOOKUP(""" & C & """,Symbol Pin Report!B:J,8,FALSE)")
Sheet60.Cells(M, 55) = Round(mymax4 / 1000, 3)
Next
'=ROUND(VLOOKUP(O2&U2&ROUND(R2*$AA$1+$Q$1,1)&"+"&ROUND(S2*$AA$1+$Q$1,1),'Symbol Pin Report'!B:J,8,FALSE)/1000,3)
'=ROUND(VLOOKUP(O2&U2&ROUND(R2*$AA$1+$Q$1,1)&"+"&ROUND(S2*$AA$1,1),'Symbol Pin Report'!B:J,8,FALSE)/1000,3)
End Sub
作者: stillfish00    時間: 2015-9-18 14:18

回復 1# rouber590324
執行圖一程式停於
  Sheet60.Cells(M, 53) = "C4  " & mymax2

自己動手debug :
在停止處的前一行插入 Stop (或出現執行階段錯誤按偵錯)
當執行停到Stop時
看區域變數視窗
是否你要的變數都合理(如 mymax2 是否為字串)

不合理再往前推原因(如 vlookup 查不到....)
作者: rouber590324    時間: 2015-9-21 11:56

DEAR  stillfish00  大大
  感謝指導  THANKS*10000




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)