View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
sebastienm sebastienm is offline
external usenet poster
 
Posts: 694
Default Input Box Question with Code

Hi,
It is because the Integer data type (type of the Result variAble) only takes
numbers from -32,768 to 32,767. Look at the excel online help topic "Data
Type SUmmary"
Instead use the Long data type which goes from -2,147,483,648 to
2,147,483,647:
Dim Response As Long

If it is still too limited, use a floating point data type, like Double.

Regards,
Sebastien


"RBBCPA" wrote:

I am trying to write a macro with an inputbox that allows a user to input a
number and then put that number in a given cell so that it can be used in
calculations (outside the macro). the code I am using is shown below. I
copied from a posted article on the microsoft site. the problem is that when
i enter a number larger than 32600, i get a run-time '6' error overflow. i
can't figure out why. i want to be able to enter numbers between 1000000 and
10000000
Sub Using_InputBox_Method()
Dim Response As Integer
Sheets("Annual Profit and Loss").Select

' Run the Input Box.
Response = Application.InputBox("Enter a number.", _
"Number Entry", , 250, 75, , 1)

' Check to see if Cancel was pressed.
If Response < False Then

' If not, write the number to the first cell in the first sheet.
Worksheets("Annual Profit and Loss").Range("c6").Value = Response

MsgBox ("Update Complete.")

End If

End Sub