Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
End Sub if InputBox cancelled (False)
Input Box Cancel button should stop the subroutine.
OK button tests to see if 'x' has been changed. I cannot see what is wrong he LastUsedRow = Sheets("Pages").Cells(Rows.Count, 5).End(xlUp).Row DoorNum = Cells(LastUsedRow, 5) x = InputBox("Door number?", _ "Additional items to door", DoorNum, 1) If x = False Then End ElseIf x < DoorNum Then DoorNum = x End If Francis Hookham |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
End Sub if InputBox cancelled (False)
Input Boxes return strings, not T/F. A Cancelled Input box returns an empty
string: "" Select Case x Case "" ' User Canceled Exit Sub Case DoorNum ' x hasn't changed: do nothing Case Else ' x has changed DoorNum = x End select "Francis Hookham" wrote in message ... Input Box Cancel button should stop the subroutine. OK button tests to see if 'x' has been changed. I cannot see what is wrong he LastUsedRow = Sheets("Pages").Cells(Rows.Count, 5).End(xlUp).Row DoorNum = Cells(LastUsedRow, 5) x = InputBox("Door number?", _ "Additional items to door", DoorNum, 1) If x = False Then End ElseIf x < DoorNum Then DoorNum = x End If Francis Hookham |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
End Sub if InputBox cancelled (False)
I think that when you cancel an input box, a zero length string is returned.
As such, replace this: If x = False Then with this: If x = "" Then -Cory "Francis Hookham" wrote: Input Box Cancel button should stop the subroutine. OK button tests to see if 'x' has been changed. I cannot see what is wrong he LastUsedRow = Sheets("Pages").Cells(Rows.Count, 5).End(xlUp).Row DoorNum = Cells(LastUsedRow, 5) x = InputBox("Door number?", _ "Additional items to door", DoorNum, 1) If x = False Then End ElseIf x < DoorNum Then DoorNum = x End If Francis Hookham |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
End Sub if InputBox cancelled (False)
If you use Application.InputBox the Cancel will = False
but with InputBox Function, Cancel = "" "Cory" wrote: I think that when you cancel an input box, a zero length string is returned. As such, replace this: If x = False Then with this: If x = "" Then -Cory "Francis Hookham" wrote: Input Box Cancel button should stop the subroutine. OK button tests to see if 'x' has been changed. I cannot see what is wrong he LastUsedRow = Sheets("Pages").Cells(Rows.Count, 5).End(xlUp).Row DoorNum = Cells(LastUsedRow, 5) x = InputBox("Door number?", _ "Additional items to door", DoorNum, 1) If x = False Then End ElseIf x < DoorNum Then DoorNum = x End If Francis Hookham |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
End Sub if InputBox cancelled (False)
Many thanks George and Cory - all's well now
I was trying to use False because I read in VBA Help - InputBox Remarks: If you choose the OK button, InputBox returns the value entered in the dialog box. If you click the Cancel button, InputBox returns False. Francis Hookham "George Nicholson" wrote in message ... Input Boxes return strings, not T/F. A Cancelled Input box returns an empty string: "" Select Case x Case "" ' User Canceled Exit Sub Case DoorNum ' x hasn't changed: do nothing Case Else ' x has changed DoorNum = x End select "Francis Hookham" wrote in message ... Input Box Cancel button should stop the subroutine. OK button tests to see if 'x' has been changed. I cannot see what is wrong he LastUsedRow = Sheets("Pages").Cells(Rows.Count, 5).End(xlUp).Row DoorNum = Cells(LastUsedRow, 5) x = InputBox("Door number?", _ "Additional items to door", DoorNum, 1) If x = False Then End ElseIf x < DoorNum Then DoorNum = x End If Francis Hookham |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
End Sub if InputBox cancelled (False)
The Entry in Excel's Help for the Application.InputBox method says that, but
the entry for the VBA InputBox function (in both Access and Excel) says: "If the user clicks Cancel, the function returns a zero-length string ("")." At least, that's what I am seeing (using Office 2003) Not specifying Application means the VBA function will be used, not the Excel method. Be careful which Help entries you are reading. Very similar objects, properties etc. can really be different under the surface across apps. *Usually* those differences are confined to how a few functions calculate or Forms (Access Forms live in their own little universe when compared to VB forms or Office Forms), but there are a few other "gotchas". This is evidently one of them. HTH, "Francis Hookham" wrote in message ... Many thanks George and Cory - all's well now I was trying to use False because I read in VBA Help - InputBox Remarks: If you choose the OK button, InputBox returns the value entered in the dialog box. If you click the Cancel button, InputBox returns False. Francis Hookham "George Nicholson" wrote in message ... Input Boxes return strings, not T/F. A Cancelled Input box returns an empty string: "" Select Case x Case "" ' User Canceled Exit Sub Case DoorNum ' x hasn't changed: do nothing Case Else ' x has changed DoorNum = x End select "Francis Hookham" wrote in message ... Input Box Cancel button should stop the subroutine. OK button tests to see if 'x' has been changed. I cannot see what is wrong he LastUsedRow = Sheets("Pages").Cells(Rows.Count, 5).End(xlUp).Row DoorNum = Cells(LastUsedRow, 5) x = InputBox("Door number?", _ "Additional items to door", DoorNum, 1) If x = False Then End ElseIf x < DoorNum Then DoorNum = x End If Francis Hookham |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hyperlink operation cancelled.... | Excel Discussion (Misc queries) | |||
Avoid unloading of .xla addins when closing books are cancelled. | Excel Programming | |||
Email Sent or Cancelled | Excel Programming | |||
Application.InputBox with Default:=0 testing False | Excel Programming | |||
Differentiate b/w False and 0 with InputBox fn | Excel Programming |