Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm using an InputBox to get info from the user. I am getting 5 numbers and strings associated with a product. Some of the numbers can be zero. I would like to have the user be able to hit cancel anytime before entering in the 5th variable to cancel the whole operation. IE, put the old info back in and prompt the user to select a new product. This works fine unless they enter 0 for a number. Here is a snippet of the code: (note: the variables are Variants so that I can test for a FALSE return from InputBox. Seperate question: could my number variables be singles instead?) TI
'This is inside a larger Do..Loop that covers entering all five variables. All five variables have loops like this below to test the input from the user D vOldCost = .Cells(RowNum, 16).Value 'Capture the old Cost dat vCost = Application.InputBox(prompt:="Enter material cost.", Type:=1 If vCost = False Then 'problem is here...user enters in 0 for cost and the If gets executed CancelProdInput vOldProduct, vOldCost, vOldType, vOldTime, vOldPrice, RowNum ' CancelProdInput puts the 'Old' data back in the correct cell GoTo LoopBegin 'go back to beginning....ask user to select product End I .Cells(RowNum, 16) = vCos Loop Until vCost = 0 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If always use
If TypeName(vCost) = "Boolean" Then 'It's False End If -- Regards Juan Pablo González "Marcotte A" wrote in message ... I'm using an InputBox to get info from the user. I am getting 5 numbers and strings associated with a product. Some of the numbers can be zero. I would like to have the user be able to hit cancel anytime before entering in the 5th variable to cancel the whole operation. IE, put the old info back in and prompt the user to select a new product. This works fine unless they enter 0 for a number. Here is a snippet of the code: (note: the variables are Variants so that I can test for a FALSE return from InputBox. Seperate question: could my number variables be singles instead?) TIA 'This is inside a larger Do..Loop that covers entering all five variables. All five variables have loops like this below to test the input from the user. Do vOldCost = .Cells(RowNum, 16).Value 'Capture the old Cost data vCost = Application.InputBox(prompt:="Enter material cost.", _ Type:=1) If vCost = False Then 'problem is here...user enters in 0 for cost and the If gets executed. CancelProdInput vOldProduct, vOldCost, _ vOldType, vOldTime, vOldPrice, RowNum ' CancelProdInput puts the 'Old' data back in the correct cells GoTo LoopBegin 'go back to beginning....ask user to select product End If .Cells(RowNum, 16) = vCost Loop Until vCost = 0 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Another solution (Juan Pablo is always a bit quicker...).
Change from: If vCost = False To: If CStr(vCost) = "False" -- Message posted from http://www.ExcelForum.com |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Cool, that seems to work.... thanks a lot.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to differentiate groups of numbers | Excel Worksheet Functions | |||
How do I differentiate between duplicate ranks? | Excel Worksheet Functions | |||
Differentiate between Number and Date? | Excel Discussion (Misc queries) | |||
True Or False, no matter what... it still displays the false statement | Excel Programming | |||
Differentiate between cell colours | Excel Programming |