Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RJH RJH is offline
external usenet poster
 
Posts: 44
Default Handling the 'Cancel' button..??

I have the following code:

Do
Msg = "Is the BILLING DATE below correct?" & Chr(10) & Chr(10) _
& "If not, Enter correct date ..."
Default = Worksheets("Sheet2").Range("N2")
BillDate = InputBox(Msg, Title, Default) ' get billing date
Worksheets("Sheet2").Range("N2") = BillDate 'Put BillDate into
Sheet2 N2

If BillDate < "" Then Exit Do
MsgBox "Please enter Billing Date", 48, Title
Loop

It works like a champ but...
How would I handle someone hitting the 'Cancel button?
At this point if 'Cancel' is pressed I get the "Please enter billing date"
msg and it loops around again.

Thanks for the help.

RJH


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Handling the 'Cancel' button..??

Hi RJH,

Try:

Do
Msg = "Is the BILLING DATE below correct?" _
& Chr(10) & Chr(10) _
& "If not, Enter correct date ..."

myDefault = Worksheets("Sheet2").Range("N2")
BillDate = InputBox(Msg, Title, myDefault)
Worksheets("Sheet2").Range("N2") = BillDate

If StrPtr(BillDate) = 0 Then
MsgBox "You cancelled"
Exit Do
End If

If BillDate < "" Then Exit Do
MsgBox "Please enter Billing Date", 48, Title
Loop


Note that I changed your Default variable to myDefault as the former is a
keyword and it use may cause problems.


---
Regards,
Norman



"RJH" wrote in message
...
I have the following code:

Do
Msg = "Is the BILLING DATE below correct?" & Chr(10) & Chr(10) _
& "If not, Enter correct date ..."
Default = Worksheets("Sheet2").Range("N2")
BillDate = InputBox(Msg, Title, Default) ' get billing date
Worksheets("Sheet2").Range("N2") = BillDate 'Put BillDate into
Sheet2 N2

If BillDate < "" Then Exit Do
MsgBox "Please enter Billing Date", 48, Title
Loop

It works like a champ but...
How would I handle someone hitting the 'Cancel button?
At this point if 'Cancel' is pressed I get the "Please enter billing date"
msg and it loops around again.

Thanks for the help.

RJH



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
vb cancel button kckar[_8_] Excel Programming 2 April 17th 06 02:39 PM
Cancel button to cancel the whole macro excelnut1954 Excel Programming 3 January 17th 06 08:27 PM
Cancel button IamHaxer Excel Programming 3 June 24th 04 05:19 PM
Cancel Button Matt Excel Programming 3 February 3rd 04 11:23 PM
input box cancel button Ian Mangelsdorf Excel Programming 1 August 28th 03 09:05 PM


All times are GMT +1. The time now is 01:21 PM.

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"