![]() |
Inputbox and cancel button
Hi All,
I am rather confused as to why the following macro does not work properly. The problem is when the user presses the cancel button without entering anything in the Inputbox it starts looping! However, if the user presses OK without entering anything in the Inputbox then it exits! Can you see why. Thanks for your help. Dim UInput as string Dim Msg as string Msg = "Enter todays date" Do UInput = Application.inputbox(Msg) If UInput = "" then Exit Sub If Isdate(UInput) then Msgbox "Thank You" Exit Do End if Msg = "You did not enter a date" Msg = Msg & vbNewLine Msg = Msg & "Enter todays date" Loop Regards UJ |
Inputbox and cancel button
When the cancel button is pressed uinput = false
You code only checks for "" This is why your code is not exiting sub modify your code If UInput = "" or Uinput = false then Exit Su -- Message posted from http://www.ExcelForum.com |
Inputbox and cancel button
The cancel button is returning a value of False
Change hte IF statement to IF UInput= False then Exit Sub That should work Andres -----Original Message----- Hi All, I am rather confused as to why the following macro does not work properly. The problem is when the user presses the cancel button without entering anything in the Inputbox it starts looping! However, if the user presses OK without entering anything in the Inputbox then it exits! Can you see why. Thanks for your help. Dim UInput as string Dim Msg as string Msg = "Enter todays date" Do UInput = Application.inputbox(Msg) If UInput = "" then Exit Sub If Isdate(UInput) then Msgbox "Thank You" Exit Do End if Msg = "You did not enter a date" Msg = Msg & vbNewLine Msg = Msg & "Enter todays date" Loop Regards UJ . |
Inputbox and cancel button
on reflection, I'm confused about why this inputbox is even necessary.
Today's date can always be found using the Date function: UInput = Date In article , (Uddinj1) wrote: I am rather confused as to why the following macro does not work properly. |
Inputbox and cancel button
Hi,
I did not get to see your reply until now. I used today's date as an example. I need a date entered depending on other issues. However, the answer you provided works and it is exteremely useful to me. Thank you. Best wishes. Regards UJ -----Original Message----- on reflection, I'm confused about why this inputbox is even necessary. Today's date can always be found using the Date function: UInput = Date In article , (Uddinj1) wrote: I am rather confused as to why the following macro does not work properly. . |
All times are GMT +1. The time now is 12:10 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com