Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2020, 05:01 AM
jmcsa3 jmcsa3 is offline vba inputbox method problems Windows 10 vba inputbox method problems Office 2019
Novice
vba inputbox method problems
 
Join Date: Jan 2019
Location: UK
Posts: 14
jmcsa3 is on a distinguished road
Default vba inputbox method problems

I'm running 365 Home, latest version, on Windows 10.
I recently discovered application.inputbox which gives the ability to define the Type of input, string, number etc. I wanted to ensure idiot proof input of data. In general this method works as described on the box but there are issues. I've used macro1() to descibe the problems:


Sub Macro1()
'
' Macro1 Macro

Dim lnWins As Variant

lnWins = Application.InputBox("give me something", Type:=1)
MsgBox lnWins

'1 Entering a number works as intended. Good
'2 Entering a non-numeric gives an error msg then returns for input. Good
'3 Cancel gives "False". Good
'4 Click x (top right) gives "False". Good
'5 Clicking OK with no entry in inputbox gives the message in attahed pic. Not good
'6 Clicking "?" opens a ms web page about ranges. Not good
End Sub 'Macro1


inputbox1.png

I have tried numerous ms websites but with no result.
Can anyone suggest workarounds to cope with items 5 & 6 above
Reply With Quote
  #2  
Old 08-26-2020, 08:36 AM
NoSparks NoSparks is offline vba inputbox method problems Windows 10 vba inputbox method problems Office 2010
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

you could omit the type=1 and deal with what's returned, something along the lines of

Code:
Sub Macro1()
    '
    ' Macro1 Macro
    
    Dim lnWins As Variant
    
    lnWins = Application.InputBox("give me something")
    
    Select Case lnWins
        Case ""
            MsgBox "InputBox was left blank"
        Case False
            MsgBox "Things got canceled"
        Case Else
            MsgBox lnWins
    End Select
End Sub
Reply With Quote
  #3  
Old 08-26-2020, 09:02 AM
jmcsa3 jmcsa3 is offline vba inputbox method problems Windows 10 vba inputbox method problems Office 2019
Novice
vba inputbox method problems
 
Join Date: Jan 2019
Location: UK
Posts: 14
jmcsa3 is on a distinguished road
Default

Yes I agree but I was hoping to avoid coding to catch bad input by moving to the "more advanced" Method as opposed to the standard Function. Regretably the Method doesn't appear to work satisfactorily and I can't see MS moving quickly to sort it.
jmcsa3
Reply With Quote
Reply

Tags
vba inputbox problem

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to add terminology via inputbox ZiggyPop Word VBA 0 03-07-2017 04:06 AM
InputBox selects rows Dave T Excel Programming 5 09-05-2016 06:58 AM
VBA Macro for word with Inputbox ryanch69 Word VBA 2 12-03-2015 07:45 AM
vba inputbox method problems Idiot Proof Entry with InputBox arpirnat Word VBA 1 04-27-2015 10:03 PM
Taking input from InputBox from user SeattleITguy Excel Programming 1 01-28-2015 09:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft