Application.Inputbox Type2

S

Steve

Hi all,

Any idea why the variable FilterCriteria below is Null? When I step
through the If FilterCriteria in Nothing Then step, it goes to exit
sub. When prompted with the inputbox, I did enter text. Thanks!

On Error Resume Next
Set FilterCriteria = Application.InputBox(prompt:= _
"Enter Filter Criteria", Type:=2)
If FilterCriteria Is Nothing Then
Exit Sub
End If
On Error GoTo 0
 
C

Clif McIrvin

Steve said:
Hi all,

Any idea why the variable FilterCriteria below is Null? When I step
through the If FilterCriteria in Nothing Then step, it goes to exit
sub. When prompted with the inputbox, I did enter text. Thanks!

On Error Resume Next
Set FilterCriteria = Application.InputBox(prompt:= _
"Enter Filter Criteria", Type:=2)
If FilterCriteria Is Nothing Then
Exit Sub
End If
On Error GoTo 0


Presumably FilterCriteria is a variant .... Set is an Object oriented
statement, and Nothing is an Object property. You are returning a text
string, which is not an object. I expect that if you take out the On
Error Resume Next you will get run-time errors that would help you
debug.

Try:
FilterCriteria = Application.InputBox(prompt:= _
"Enter Filter Criteria", Type:=2)
If IsEmpty(FilterCriteria) Then
Exit Sub
End If

You can put the On Error back in after you finish your testing.
 
S

Steve

Right on the money! Thanks Clif!!

Presumably FilterCriteria  is a variant .... Set is an Object oriented
statement, and Nothing is an Object property. You are returning a text
string, which is not an object. I expect that if you take out the On
Error Resume Next you will get run-time errors that would help you
debug.

Try:
     FilterCriteria = Application.InputBox(prompt:= _
            "Enter Filter Criteria", Type:=2)
        If IsEmpty(FilterCriteria) Then
            Exit Sub
        End If

You can put the On Error back in after you finish your testing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top