-1

これは、委員会のレポートのコードの文字列です。毎日問題なく正常に動作し、13 日に最後に実行されました。

今朝、私は を受け取っていRun Time Error 13 Type Mismatchます。

理由はわかりませんが、デバッグすると、次のセクションが強調表示されます。

If UCase(Cells(i, 1).Value = "200265 - MP"それで

再入力しようとしましたが、入力すると、単語のエラーが表示されます次に、次のように述べています。 Compile error: Expected: list seperator or )

どうすればこれを実行できますか?

コードは次のとおりです。

Sheets("Errors").Select
Cells.Select
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
Sheets("Errors").Select
With Sheets("Errors")
    lastrow = .Range("C" & Rows.Count).End(xlUp).Row
End With
For i = lastrow To 1 Step -1
    Cells(i, 1).Select
    If UCase(Cells(i, 1).Value = "200265 - MP" Then
        Rows(i).Select
        Selection.Cut
        Sheets("Temp").Select
        Rows("1:1").Select
        Selection.Insert Shift:=xlDown
        Sheets("Errors").Select
    End If
    If UCase(Cells(i, 1).Value) = "160850 - TP" Then
        Rows(i).Select
        Selection.Cut
        Sheets("Temp").Select
        Rows("1:1").Select
        Selection.Insert Shift:=xlDown
        Sheets("Errors").Select
    End If
    If UCase(Cells(i, 1).Value) = "170566 - VB" Then
        Rows(i).Select
        Selection.Cut
        Sheets("Temp").Select
        Rows("1:1").Select
        Selection.Insert Shift:=xlDown
        Sheets("Errors").Select
    End If
    If UCase(Cells(i, 1).Value) = "201447 - JB" Then
        Rows(i).Select
        Selection.Cut
        Sheets("Temp").Select
        Rows("1:1").Select
        Selection.Insert Shift:=xlDown
        Sheets("Errors").Select
    End If
    If UCase(Cells(i, 1).Value) = "202006 - BL" Then
        Rows(i).Select
        Selection.Cut
        Sheets("Temp").Select
        Rows("1:1").Select
        Selection.Insert Shift:=xlDown
        Sheets("Errors").Select
    End If
    If UCase(Cells(i, 1).Value) = "203646 - MM" Then
        Rows(i).Select
        Selection.Cut
        Sheets("Temp").Select
        Rows("1:1").Select
        Selection.Insert Shift:=xlDown
        Sheets("Errors").Select
    End If
    If UCase(Cells(i, 1).Value) = "203917 - KT" Then
        Rows(i).Select
        Selection.Cut
        Sheets("Temp").Select
        Rows("1:1").Select
        Selection.Insert Shift:=xlDown
        Sheets("Errors").Select
    End If
4

2 に答える 2

1

ブラケットを閉じるのを忘れました: writeUCase(Cells(i, 1).Value) = "200265 - MP" Then

編集:

コメントから何が起こっているのかを理解するのは難しいです。これを試してください: この関数をモジュールに貼り付けます

Public Function myUCase(ByVal v As Variant) As String
    On Error GoTo error:

    myUCase = UCase(CStr(v))
    Exit Function

error:
    myUCase = ""

End Function

次に、UCase への呼び出しを myUCase への呼び出しに置き換えます。

私がここでやっていることは、エラーを捨てることです。

ただし、ある程度の注意を払って使用してください。

于 2013-06-17T13:04:10.757 に答える
0

ブラケットが足りないようです

If UCase(Cells(i, 1).Value = "200265 - MP" Then

する必要があります

If UCase(Cells(i, 1).Value) = "200265 - MP" Then
于 2013-06-17T13:04:42.117 に答える