Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Restrict Input of InputBox to numeric values between 1 and 10

Dear Experts:

below code snippet lets user change the font size of a chart's data
labels by means of an Input Box.

I would like the inputbox part of the macro expanded in the following
way:

.... only numeric values between 1 and 10 are allowed (ie. Font size of
the data labels)
.... If above condition is not met the inputbox dialog is to re-appear.
In the current state the macro exits on non-numeric values.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas



DefineFontSize = InputBox("Specifiy the new Font Size of the Data
Labels!")
If Not IsNumeric(DefineFontSize) Then
MsgBox ("Only numeric values are allowed!")
Exit Sub
End If
If DefineFontSize = "" Then
Exit Sub
End If

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Restrict Input of InputBox to numeric values between 1 and 10

hi,

Code:
Sub Macro1()
'expression.InputBox(Prompt, Title, Default, Left, Top, HelpFile, HelpContextId, Type)
Dim MyTitle As String, MyMessage As String, DefineFontSize As Integer
MyTile = "Specifiy the new Font Size of the DataLabels! "
MyMessage = "Enter number between 1 and 10"
repeat:
DefineFontSize = Int(Application.InputBox(Prompt:=MyMessage, Title:=MyTile, Default:=1, Type:=1))
If DefineFontSize <= 0 Or DefineFontSize  9 Then
    MsgBox "You must enter number between 1 and 10, or cancel !"
    GoTo repeat
End If
End Sub

--
isabelle

Le 2011-04-20 12:31, AndreasHermle a écrit :
Dear Experts:

below code snippet lets user change the font size of a chart's data
labels by means of an Input Box.

I would like the inputbox part of the macro expanded in the following
way:

... only numeric values between 1 and 10 are allowed (ie. Font size of
the data labels)
... If above condition is not met the inputbox dialog is to re-appear.
In the current state the macro exits on non-numeric values.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas



DefineFontSize = InputBox("Specifiy the new Font Size of the Data
Labels!")
If Not IsNumeric(DefineFontSize) Then
MsgBox ("Only numeric values are allowed!")
Exit Sub
End If
If DefineFontSize = "" Then
Exit Sub
End If

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Restrict Input of InputBox to numeric values between 1 and 10

On Apr 20, 12:31*pm, AndreasHermle
wrote:
Dear Experts:

below code snippet lets user change the font size of a chart's data
labels by means of an Input Box.

I would like the inputbox part of the macro expanded in the following
way:

... only numeric values between 1 and 10 are allowed (ie. Font size of
the data labels)
... If above condition is not met the inputbox dialog is to re-appear.
In the current state the macro exits on non-numeric values.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

DefineFontSize = InputBox("Specifiy the new Font Size of the Data
Labels!")
If Not IsNumeric(DefineFontSize) Then
MsgBox ("Only numeric values are allowed!")
Exit Sub
End If
If DefineFontSize = "" Then
Exit Sub
End If


How about this (with type declarations included - a good practice):

Sub Test()
Dim answer As String
Dim DefineFontSize As Double

answer = InputBox("Specifiy the new Font Size of the Data Labels!")
If Not IsNumeric(answer) Then
MsgBox ("Only numeric values are allowed!")
Exit Sub
End If
DefineFontSize = answer
Do While DefineFontSize < 1 Or DefineFontSize 10
MsgBox "Font size should be in range 1 to 10"
answer = InputBox("Specifiy the new Font Size of the Data
Labels!")
If Not IsNumeric(answer) Then
MsgBox ("Only numeric values are allowed!")
Exit Sub
End If
DefineFontSize = answer
Loop
MsgBox DefineFontSize
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Restrict Input of InputBox to numeric values between 1 and 10

On Apr 20, 7:01*pm, isabelle wrote:
hi,

Code:
 Sub Macro1()
 'expression.InputBox(Prompt, Title, Default, Left, Top, HelpFile, HelpContextId, Type)
 Dim MyTitle As String, MyMessage As String, DefineFontSize As Integer
 MyTile = "Specifiy the new Font Size of the DataLabels! "
 MyMessage = "Enter number between 1 and 10"
 repeat:
 DefineFontSize = Int(Application.InputBox(Prompt:=MyMessage, Title:=MyTile, Default:=1, Type:=1))
 If DefineFontSize <= 0 Or DefineFontSize  9 Then
 * * MsgBox "You must enter number between 1 and 10, or cancel !"
 * * GoTo repeat
 End If
 End Sub

--
isabelle

Le 2011-04-20 12:31, AndreasHermle a écrit :







Dear Experts:


below code snippet lets user change the font size of a chart's data
labels by means of an Input Box.


I would like the inputbox part of the macro expanded in the following
way:


... only numeric values between 1 and 10 are allowed (ie. Font size of
the data labels)
... If above condition is not met the inputbox dialog is to re-appear.
In the current state the macro exits on non-numeric values.


Help is much appreciated. Thank you very much in advance.


Regards, Andreas


DefineFontSize = InputBox("Specifiy the new Font Size of the Data
Labels!")
If Not IsNumeric(DefineFontSize) Then
MsgBox ("Only numeric values are allowed!")
Exit Sub
End If
If DefineFontSize = "" Then
Exit Sub
End If


Hi Isabelle,

great coding. Thank you very much for your kind and professional
help.

Regards, Andreas
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Restrict Input of InputBox to numeric values between 1 and 10

On Apr 20, 7:12*pm, scattered wrote:
On Apr 20, 12:31*pm, AndreasHermle
wrote:









Dear Experts:


below code snippet lets user change the font size of a chart's data
labels by means of an Input Box.


I would like the inputbox part of the macro expanded in the following
way:


... only numeric values between 1 and 10 are allowed (ie. Font size of
the data labels)
... If above condition is not met the inputbox dialog is to re-appear.
In the current state the macro exits on non-numeric values.


Help is much appreciated. Thank you very much in advance.


Regards, Andreas


DefineFontSize = InputBox("Specifiy the new Font Size of the Data
Labels!")
If Not IsNumeric(DefineFontSize) Then
MsgBox ("Only numeric values are allowed!")
Exit Sub
End If
If DefineFontSize = "" Then
Exit Sub
End If


How about this (with type declarations included - a good practice):

Sub Test()
Dim answer As String
Dim DefineFontSize As Double

answer = InputBox("Specifiy the new Font Size of the Data Labels!")
If Not IsNumeric(answer) Then
* * MsgBox ("Only numeric values are allowed!")
* * Exit Sub
End If
DefineFontSize = answer
Do While DefineFontSize < 1 Or DefineFontSize 10
* * MsgBox "Font size should be in range 1 to 10"
* * answer = InputBox("Specifiy the new Font Size of the Data
Labels!")
* * If Not IsNumeric(answer) Then
* * * * MsgBox ("Only numeric values are allowed!")
* * * * Exit Sub
* * End If
* * DefineFontSize = answer
Loop
MsgBox DefineFontSize
End Sub


Dear Scattered,

works like a charm. thank you very much for your professional help.

regards, Andreas
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 restrict input to a list of values - with a twist Rod Excel Worksheet Functions 7 January 5th 09 05:26 AM
Need Input Box to only Accept Numeric Values [email protected] Excel Programming 6 February 3rd 07 09:26 PM
How do I restrict an inputbox to 5<= string characters? Gabe Tiger Excel Programming 1 May 13th 06 07:08 AM
How do I restrict entry into a cell to only alpha/numeric? SusanMurray Excel Worksheet Functions 3 May 5th 06 03:23 PM
Restrict user entry to numeric values only Nicole D. Excel Programming 1 October 25th 05 10:15 PM


All times are GMT +1. The time now is 09:14 PM.

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"