Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default Test for Cancel in Inputbox

I have the following code segment:

StartDate = Date

StartDate = Application.InputBox("First valid date", , StartDate, , , , , 1)

How can I tell if the user clicked Cancel instead of OK?


--
Regards,
Fred



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Test for Cancel in Inputbox

Hi Fred,

StartDate = Application.InputBox("First valid date", , StartDate, , , , , 1)
If StartDate = False Then
MsgBox "User pressed cancel"
End If



--
Hope that helps.

Vergel Adriano


"Fred Smith" wrote:

I have the following code segment:

StartDate = Date

StartDate = Application.InputBox("First valid date", , StartDate, , , , , 1)

How can I tell if the user clicked Cancel instead of OK?


--
Regards,
Fred




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default Test for Cancel in Inputbox

Thanks, Vergel.

Does that mean I need StartDate to be type Variant, rather than Date?

--
Regards,
Fred


"Vergel Adriano" wrote in message
...
Hi Fred,

StartDate = Application.InputBox("First valid date", , StartDate, , , , , 1)
If StartDate = False Then
MsgBox "User pressed cancel"
End If



--
Hope that helps.

Vergel Adriano


"Fred Smith" wrote:

I have the following code segment:

StartDate = Date

StartDate = Application.InputBox("First valid date", , StartDate, , , , , 1)

How can I tell if the user clicked Cancel instead of OK?


--
Regards,
Fred






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Test for Cancel in Inputbox

It seems that you don't need to define StartDate as a variant.


Sub test()
Dim StartDate As Date

StartDate = Date

StartDate = Application.InputBox("First valid date", , StartDate, , , , , 1)

If StartDate = False Then
MsgBox "User pressed cancel"
End If

'this also works
If StartDate = #12:00:00 AM# Then
MsgBox "User pressed cancel"
End If

'and this one too
If StartDate = 0 Then
MsgBox "User pressed cancel"
End If

End Sub


--
Hope that helps.

Vergel Adriano


"Fred Smith" wrote:

Thanks, Vergel.

Does that mean I need StartDate to be type Variant, rather than Date?

--
Regards,
Fred


"Vergel Adriano" wrote in message
...
Hi Fred,

StartDate = Application.InputBox("First valid date", , StartDate, , , , , 1)
If StartDate = False Then
MsgBox "User pressed cancel"
End If



--
Hope that helps.

Vergel Adriano


"Fred Smith" wrote:

I have the following code segment:

StartDate = Date

StartDate = Application.InputBox("First valid date", , StartDate, , , , , 1)

How can I tell if the user clicked Cancel instead of OK?


--
Regards,
Fred







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Test for Cancel in Inputbox

Yes.

Fred Smith wrote:
Thanks, Vergel.

Does that mean I need StartDate to be type Variant, rather than Date?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default Test for Cancel in Inputbox

Thanks for your help. It was exactly what I was looking for. It works like a
charm and, as you say, without needing to use Variant.

--
Regards,
Fred


"equiangular" wrote in message
...
Yes.

Fred Smith wrote:
Thanks, Vergel.

Does that mean I need StartDate to be type Variant, rather than Date?



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
How do I capture CANCEL on an Inputbox? Toxicdistortion Excel Programming 3 October 27th 06 01:23 AM
InputBox - cancel button Greg Billinge Excel Programming 4 October 11th 04 06:45 PM
InputBox Function & Cancel Otto Moehrbach[_6_] Excel Programming 4 September 30th 04 01:13 AM
Clicking Cancel on an Inputbox rott[_6_] Excel Programming 3 March 5th 04 02:57 AM
Inputbox and cancel button Uddinj1 Excel Programming 5 March 2nd 04 11:27 AM


All times are GMT +1. The time now is 09:57 PM.

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

About Us

"It's about Microsoft Excel"