If Not C Is Nothing And Tcode<> "" Then b1 = C.Offset(, 4).Value Else b1 = 0
If Not C Is Nothing And Tcode<> "" Then b2 = C.Offset(, 6).Value Else b2 = 0
If Not C Is Nothing And Tcode<> "" Then b3 = C.Offset(, 8).Value Else b3 = 0
If Not C Is Nothing And Tcode<> "" Then b4 = C.Offset(, 10).Value Else b4 = 0作者: jcchiang 時間: 2013-12-10 11:47
目前問題已解決,另外請教一個問題
我想把0改為顯示"N/A"
If Not C Is Nothing And TCode <> "" Then b1 = C.Offset(, 4).Value Else b1 = "N/A"
If Not C Is Nothing And TCode <> "" Then b2 = C.Offset(, 6).Value Else b2 = "N/A"
If Not C Is Nothing And TCode <> "" Then b3 = C.Offset(, 8).Value Else b3 = "N/A"
If Not C Is Nothing And TCode <> "" Then b4 = C.Offset(, 10).Value Else b4 = "N/A"
但是執行到
Ar(i + 4) = Array(A.Offset(i, -5).Value, A.Offset(i, 0).Value, A.Offset(i, 2).Value, Cnt, TCode, b1, b1 / Cnt, b2, b2 / Cnt, b3, b3 / Cnt, b4, b4 / Cnt)
會顯示型態不符合,是否是要另外定義參數型態作者: Hsieh 時間: 2013-12-10 15:11
Sub ex()
Dim Ar(0 To 7), A As Range, C As Range, TCode, Cnt
最後一個程式碼可以將0改成NA,但第2種情況無法執行(有TCode在Sheet1查無資料)
目前將B1~B4資料改成
If Not C Is Nothing And TCode <> "" Then b1 = C.Offset(, 4).Value
If Not C Is Nothing And TCode <> "" Then b2 = C.Offset(, 6).Value
If Not C Is Nothing And TCode <> "" Then b3 = C.Offset(, 8).Value
If Not C Is Nothing And TCode <> "" Then b4 = C.Offset(, 10).Value
則可執行第2種情形
感謝H大耐心的指導,謝謝