Reputation: 1276
MY inputbox allow user to input a value into a cell. Therefore I wish to filter some input like =SUM(A:A)
and '
which will show nothing, and other formula or possibly entry that will affect the actual value. Thanks in advance.
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
Upvotes: 0
Views: 1216
Reputation: 19077
You could use different attempts to filter some or all required values. Keep in mind that you y variable
is string type. Therefore here are some of ideas with some comments:
'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
you could combine them all into one if...then
statement using and
or or
operators.
Upvotes: 1