Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following code:
vAmount = ActiveCell.Value Dim EnterAmount As Variant EnterAmount = InputBox("Enter the amount to Hardcode: ", , vAmount) If EnterAmount < "" Then ActiveCell.Value = EnterAmount End If Now if I hit cancel the amount will remain what it was. But if I use Application.InputBox: EnterAmount = Application.InputBox("Enter the amount to Hardcode: ", , vAmount, , , , , Type:=1) then if I hit Cancel I will get a False in the cell. How do I make it so if I hit Cancel with using the Application.Input box the cell will not change to False but will remain what the cell was when I entered the cell like the InputBox does. Thank you for your help, Steven |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim EnterAmount As Variant
EnterAmount = Application.InputBox(Prompt:="Enter the amount to Hardcode:", _ Type:=1) If EnterAmount = False Then 'what should happen? Else 'do the real work activecell.value = enteramount end if Steven wrote: I have the following code: vAmount = ActiveCell.Value Dim EnterAmount As Variant EnterAmount = InputBox("Enter the amount to Hardcode: ", , vAmount) If EnterAmount < "" Then ActiveCell.Value = EnterAmount End If Now if I hit cancel the amount will remain what it was. But if I use Application.InputBox: EnterAmount = Application.InputBox("Enter the amount to Hardcode: ", , vAmount, , , , , Type:=1) then if I hit Cancel I will get a False in the cell. How do I make it so if I hit Cancel with using the Application.Input box the cell will not change to False but will remain what the cell was when I entered the cell like the InputBox does. Thank you for your help, Steven -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave showed you the code. The explanation is that for InputBox function,
cancel equals "". For InputBox Method, cancel equals "False". So if you use Application.InputBut you have to change your "If" statement to match whatever cancel equals. "Dave Peterson" wrote: Dim EnterAmount As Variant EnterAmount = Application.InputBox(Prompt:="Enter the amount to Hardcode:", _ Type:=1) If EnterAmount = False Then 'what should happen? Else 'do the real work activecell.value = enteramount end if Steven wrote: I have the following code: vAmount = ActiveCell.Value Dim EnterAmount As Variant EnterAmount = InputBox("Enter the amount to Hardcode: ", , vAmount) If EnterAmount < "" Then ActiveCell.Value = EnterAmount End If Now if I hit cancel the amount will remain what it was. But if I use Application.InputBox: EnterAmount = Application.InputBox("Enter the amount to Hardcode: ", , vAmount, , , , , Type:=1) then if I hit Cancel I will get a False in the cell. How do I make it so if I hit Cancel with using the Application.Input box the cell will not change to False but will remain what the cell was when I entered the cell like the InputBox does. Thank you for your help, Steven -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
application.inputbox | Excel Programming | |||
Inputbox and Application.InputBox | Excel Programming | |||
inputbox and application.run macro1 | Excel Programming | |||
application.inputbox | Excel Programming | |||
Application.Inputbox Question | Excel Programming |