Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Clicking Cancel on an Inputbox

Hi I currently have a macro that brings up an input box. The inputbo
allows the user to enter in a date and if they click ok it proceed
with the rest of the macro.

If the user hits cancel or the x in the corner of the inputbox i
continues to loop until they enter a correct date in. What I am tryin
to do is have the macro end if they hit the cancel button.

Can someone help me out?

Thanks!

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Clicking Cancel on an Inputbox

Excel does not capture details of which button is pressed


Ans = InputBox("Prompt", "title")
If Ans = "" Then
End
End If

You will get the same response if the user presses the ok butto
without entering anything as the user pressing the cancel button

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default Clicking Cancel on an Inputbox

Use Application.Inputbox - it returns the value False if canceled.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"rott " wrote in message
...
Hi I currently have a macro that brings up an input box. The inputbox
allows the user to enter in a date and if they click ok it proceeds
with the rest of the macro.

If the user hits cancel or the x in the corner of the inputbox it
continues to loop until they enter a correct date in. What I am trying
to do is have the macro end if they hit the cancel button.

Can someone help me out?

Thanks!!


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Clicking Cancel on an Inputbox

From a previous post of mine

Const Msg1 As String = "Enter today's date"
Const Msg2 As String = "You did not enter a valid date." & _
vbNewLine & "Please enter today's date"
Dim UInput As Variant
Dim bLoop As Boolean

Do
UInput = Application.InputBox( _
Prompt:=IIf(bLoop, Msg2, Msg1), _
Default:=Date)
If UInput = False Then Exit Sub
bLoop = True
Loop Until IsDate(UInput)

In article ,
rott wrote:

Hi I currently have a macro that brings up an input box. The inputbox
allows the user to enter in a date and if they click ok it proceeds
with the rest of the macro.

If the user hits cancel or the x in the corner of the inputbox it
continues to loop until they enter a correct date in. What I am trying
to do is have the macro end if they hit the cancel button.

Can someone help me out?

Thanks!!


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting Cancel in an InputBox Method Connie Excel Discussion (Misc queries) 2 October 19th 06 01:32 PM
Inputbox or msgbox critical + Cancel Syrus the Virus[_18_] Excel Programming 2 March 2nd 04 01:28 PM
Inputbox and cancel button Uddinj1 Excel Programming 5 March 2nd 04 11:27 AM
Cancel button in Inputbox method MiRa Excel Programming 2 November 14th 03 01:04 PM
Inputbox method using type:=8 - How to Cancel? Joe 90 Excel Programming 0 July 10th 03 12:24 AM


All times are GMT +1. The time now is 03:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"