Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Alex,
If you really mean an Integer (a whole number between -32,768 to 32,767) use this, otherwise change accordingly for Long, Double etc : Dim Question3 As String, Title3 As String Dim ChangeLevel As Variant Const DftInt As Integer = 0 Const NumbersOnly As Long = 1 Question3 = "What is the Change Level?" Title3 = "Change Level" ChangeLevel = Application.InputBox(Question3, Title3, DftInt, , , , , NumbersOnly) If ChangeLevel = False Then Exit Sub End If See if the result can coerced into an Int On Error Resume Next Range("E5").Value = CInt(ChangeLevel) If Err.Number 0 Then MsgBox "Out of range" Range("E5").Value = CVErr(xlErrNum) End If On Error GoTo 0 NickHK "Alex" wrote in message ... I have the following code that inputs a value into a cell that is typed in an input box. How can I force the number that is typed in the input box to be an integer? Thanks. Sub Input_Fields() Dim Question3, Title3, Default3, Box3 Dim ChangeLevel As Integer Question3 = "What is the Change Level?" Title3 = "Change Level" Default3 = "" ChangeLevel = InputBox(Question3, Title3, Default3) Range("e5").Select ActiveCell.FormulaR1C1 = ChangeLevel End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I add an integer to an existing integer? | Excel Worksheet Functions | |||
integer | Excel Worksheet Functions | |||
Inputbox and Application.InputBox | Excel Programming | |||
Get next Integer value | Excel Programming | |||
Not seeing integer | Excel Programming |