0

MY 入力ボックスを使用すると、ユーザーはセルに値を入力できます。=SUM(A:A)したがって、何も表示されないandのような入力'と、実際の値に影響を与える他の数式またはエントリをフィルター処理したいと考えています。前もって感謝します。

Private Sub testInputBox_Click()
    Dim x As String
    Dim y As String
    Dim yDefault As String
    Dim found As Range

    x = InputBox("Enter Parts No.", "Edit Description")

    If (x <> "") Then
        If (WorksheetFunction.CountIf(Worksheets("Sheet1").Range("E2:E27"), x) > 0) Then
            Set found = Worksheets("Sheet1").Range("E2:E27").Find(x, LookIn:=xlValues)
            yDefault = found.Offset(0, 1).Text
            y = InputBox("Amend Description", "Edit Description", yDefault)
        Else
            MsgBox ("Not found!")
        End If

        If (y <> "") Then 'Filter should be done here
            If MsgBox("Proceed to edit?", vbYesNo, "Confirmation") = vbNo Then
            Else
                found.Offset(0, 1).Value = CStr(y)
            End If

        End If
    End If
End Sub
4

1 に答える 1

1

必要な値の一部またはすべてをフィルタリングするために、さまざまな試行を使用できます。あなたy variableは文字列型であることを覚えておいてください。したがって、いくつかのコメントを含むいくつかのアイデアを次に示します。

'tests for starting characters
If y <> "'" And y <> "=" Then
    'test for formulas
    If UCase(Left(y, 4)) <> "=SUM" Then
        'test for any string within other string
        If InStr(1, y, "sum", vbTextCompare) = 0 Then
            '...here your code
        End If
    End If
End If

or演算子if...thenを使用して、それらすべてを 1 つのステートメントに結合できます。andor

于 2013-04-23T06:15:31.683 に答える