Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Input Box - CANCEL
Hi,
Please edit the macro below so when the user clicks on CANCEL or CLOSE the box, Range A1 existing input won't change. Sub InputNumber() Range("A1").Value = InputBox("What is the number?") End Sub Thank you. |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Input Box - CANCEL
Try:
Sub test() Dim varResult As Variant varResult = InputBox("Input") If IsNumeric(varResult) Then _ Range("A1").Value = varResult End Sub "Danny" wrote: Hi, Please edit the macro below so when the user clicks on CANCEL or CLOSE the box, Range A1 existing input won't change. Thank you. |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Input Box - CANCEL
Sub InputNumber()
res = InputBox("What is the number?") If res = "" Then Exit Sub End If End Sub "Danny" wrote in message ... Hi, Please edit the macro below so when the user clicks on CANCEL or CLOSE the box, Range A1 existing input won't change. Sub InputNumber() Range("A1").Value = InputBox("What is the number?") End Sub Thank you. |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Input Box - CANCEL
Danny
I would tend to check for nothing entered or wrong data type entered. Sub InputNumber() selectnum = InputBox("What is the number?") If selectnum = "" Or Not IsNumeric(selectnum) Then Exit Sub Range("A1").Value = selectnum End Sub Gord Dibben MS Excel MVP On Mon, 27 Nov 2006 15:32:02 -0800, Danny wrote: Hi, Please edit the macro below so when the user clicks on CANCEL or CLOSE the box, Range A1 existing input won't change. Sub InputNumber() Range("A1").Value = InputBox("What is the number?") End Sub Thank you. |
#5
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Input Box - CANCEL
Gord,
Your macro is the one I used. I tried some variables so I can use formula in the input box and came up with: If selectnum = "" Then Exit Sub Thank you all! "Gord Dibben" wrote: Danny I would tend to check for nothing entered or wrong data type entered. Sub InputNumber() selectnum = InputBox("What is the number?") If selectnum = "" Or Not IsNumeric(selectnum) Then Exit Sub Range("A1").Value = selectnum End Sub Gord Dibben MS Excel MVP On Mon, 27 Nov 2006 15:32:02 -0800, Danny wrote: Hi, Please edit the macro below so when the user clicks on CANCEL or CLOSE the box, Range A1 existing input won't change. Sub InputNumber() Range("A1").Value = InputBox("What is the number?") End Sub Thank you. |
#6
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Input Box - CANCEL
OK
I guess you have some other means of ensuring that non-numerics are entered. Otherwise a text entry could give errors in your formulas if they reference A1. Gord On Tue, 28 Nov 2006 09:20:01 -0800, Danny wrote: Gord, Your macro is the one I used. I tried some variables so I can use formula in the input box and came up with: If selectnum = "" Then Exit Sub Thank you all! "Gord Dibben" wrote: Danny I would tend to check for nothing entered or wrong data type entered. Sub InputNumber() selectnum = InputBox("What is the number?") If selectnum = "" Or Not IsNumeric(selectnum) Then Exit Sub Range("A1").Value = selectnum End Sub Gord Dibben MS Excel MVP On Mon, 27 Nov 2006 15:32:02 -0800, Danny wrote: Hi, Please edit the macro below so when the user clicks on CANCEL or CLOSE the box, Range A1 existing input won't change. Sub InputNumber() Range("A1").Value = InputBox("What is the number?") End Sub Thank you. |
#7
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Input Box - CANCEL
If it there are different meanings to an empty string returned by the user
clicking OK and an empty string returned by the user clicking Cancel, use code like the following: Dim Res As String Res = InputBox("What is the number?") If StrPtr(Res) = 0 Then MsgBox "User Clicked Cancel" ElseIf Res = vbNullString Then MsgBox "User Clicked OK with no input" Else MsgBox "User Entered " & Res End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Corey" wrote in message ... Sub InputNumber() res = InputBox("What is the number?") If res = "" Then Exit Sub End If End Sub "Danny" wrote in message ... Hi, Please edit the macro below so when the user clicks on CANCEL or CLOSE the box, Range A1 existing input won't change. Sub InputNumber() Range("A1").Value = InputBox("What is the number?") End Sub Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to Prevent Duplicate Data from inputing using input application? | Excel Worksheet Functions | |||
How to Prevent Duplicate Data from inputing using input application? | Excel Discussion (Misc queries) | |||
cancel input | Excel Discussion (Misc queries) | |||
input box | Excel Discussion (Misc queries) | |||
Input Form vba help | Excel Discussion (Misc queries) |