Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 148
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 276
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 148
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7,247
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Prevent Duplicate Data from inputing using input application? Zigball Excel Worksheet Functions 8 October 16th 06 11:01 PM
How to Prevent Duplicate Data from inputing using input application? Zigball Excel Discussion (Misc queries) 1 October 10th 06 05:56 PM
cancel input ME @ Home Excel Discussion (Misc queries) 1 February 22nd 06 09:49 AM
input box Monty Excel Discussion (Misc queries) 2 October 7th 05 08:33 AM
Input Form vba help mdalzell Excel Discussion (Misc queries) 0 April 8th 05 03:57 PM


All times are GMT +1. The time now is 09:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"