Input Box not working properly

lionelnz

Well-known Member
Joined
Apr 6, 2006
Messages
571
I want activate an input box (using VBOkCancel) if there is a zero or null value in a cell.

If per chance the user does not enter a number using the input box I want the the sub to select the cell and then exit the sub.

My problem is that the input box is not coming up empty. It has the value 1 in it which is interfering with the purpose of the sub. Here is the sub (BTW rFall is dimmed as integer) -

Code:
If Range("B21").Value = "" Then
            rFall = Application.InputBox("Enter rainfall in mls", "Rainfall", vbOKCancel, 1)
                If rFall = "" Then
                Range("B21").Select
                Exit Sub
                Else
                End If
       Else
           
       End If
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
you had the vbOKCancel in the "default" parameter ..... vbOKCancel = 1

tip: click between the ( and the " in the inputbox line to place the text cursor there
then press the spacebar

you should see the command help tooltip pop up describing the parameter that you are entering

then use the right arrow key to move the cursor, and watch the tooltip

one of the parameters is [default]

Code:
Sub aa()

    If Range("B21").Value = "" Then
        rFall = Application.InputBox("Enter rainfall in mls", "Rainfall", "", , , , , vbOKCancel)
        If rFall = "" Then
            Range("B21").Select
            Exit Sub
        End If
    End If


End Sub
 
Last edited:
Upvote 0
Thanks for this it works fine. The only problem I had was the line

If rFall = "" Then

I had to change it to
If rFall = 0 Then because of dimming rFall as Integer

Lionel
Go the Wallabies & Kangaroos!!!!!!:cool::cool::cool::cool:</pre>
 
Upvote 0

Forum statistics

Threads
1,216,175
Messages
6,129,310
Members
449,499
Latest member
HockeyBoi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top