返回列表 上一主題 發帖

EXCEL VBA 請益

EXCEL VBA 請益

請問前輩
常常會出現錯誤訊息型態錯誤,請問VBA 假設 Cells(4, 26)為N/A , 要用什方式by pass &濾掉。

bug.jpg (11.13 KB)

bug畫面

bug.jpg

回復 1# itskk

真的是n/a
     If Not IsError(Cells(4, 26)) Then
    程式碼        
    End If
  
文字的n/a  
    If Cells(4, 26) <> "N/A" Then
    程式碼
    End If

TOP

回復 2# quickfixer

謝謝分享。使用大大的方式Not IsErrorCells 會顯示沒有定義sub 或 function  請問大大有遇過嗎?

    If Not IsErrorCells(Y, 58) > Not IsErrorCells(Y, 26) Then   


For Y = 4 To 1674 '有幾行要改數字(後面要加自動數字)

    If Not IsErrorCells(Y, 58) > Not IsErrorCells(Y, 26) Then         
         If Not IsErrorCells(Y, 57) > Not IsErrorCells(Y, 26) Then
              If Not IsError(Cells(Y, 8) - Not IsErrorCells(Y, 26)) / Not IsErrorCells(Y, 26) > 0.025 Then
                  Cells(Y, 26).Interior.ColorIndex = 2
              Else
                  Cells(Y, 26).Interior.ColorIndex = 18
              End If
         Else
              If Not IsErrorCells(Y, 8) < Not IsErrorCells(Y, 26) Then
                  If Not IsErrorCells(Y, 11) > 0.5 Then
                  Cells(Y, 26).Interior.ColorIndex = 10
                  Else
                  Cells(Y, 26).Interior.ColorIndex = 4
                  End If
              Else
                  Cells(Y, 26).Interior.ColorIndex = 27
              End If
         End If

BUG2.jpg (10.26 KB)

BUG2.jpg

TOP

不好意思VBA是要濾掉  #N/A
回復  itskk



真的是n/a
     If Not IsError(Cells(4, 26)) Then
    程式碼        
    End If
  ...
quickfixer 發表於 2022-9-11 20:15

TOP

回復 4# itskk

不能用是打錯字,那個多格要一次檢查才行

    If IsError(Cells(y, 8)) Or IsError(Cells(y, 11)) Or IsError(Cells(y, 26)) Or IsError(Cells(y, 57)) Or IsError(Cells(y, 58)) Then
        '其中一格有n/a
    Else
        原本的程式碼
    End If

TOP

謝謝您可以了
回復  itskk

不能用是打錯字,那個多格要一次檢查才行

    If IsError(Cells(y, 8)) Or IsError(Cell ...
quickfixer 發表於 2022-9-11 21:03

TOP

        靜思自在 : 多做多得。少做多失。
返回列表 上一主題