Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
can some one explain why this doesnt work? Sub test() Dim i as Integer Dim max as Integer Set max = InputBox(Prompt:="How many reports to create?, Title:="Create Reports", Type:=1) msgbox max End Sub fyi in the code window the set max is all on one line |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try the below
Sub test() Dim i As Integer, varMax As Variant varMax = "0" & InputBox("How many reports to create?", _ "Create Reports", 0) If IsNumeric(varMax) Then MsgBox varMax End Sub If this post helps click Yes --------------- Jacob Skaria "thomas donino" wrote: Hello, can some one explain why this doesnt work? Sub test() Dim i as Integer Dim max as Integer Set max = InputBox(Prompt:="How many reports to create?, Title:="Create Reports", Type:=1) msgbox max End Sub fyi in the code window the set max is all on one line |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Only object variables like range objects require 'Set', and you miss a double quote sign after the question sign. Type property is not used with Input box function, only when you use Inputbox Method (Application.Inputbox(...)) Sub test() Dim i As Integer Dim max As Integer max = InputBox(Prompt:="How many reports to create?", Title:="Create Reports ") MsgBox max End Sub Regards, Per "thomas donino" skrev i meddelelsen ... Hello, can some one explain why this doesnt work? Sub test() Dim i as Integer Dim max as Integer Set max = InputBox(Prompt:="How many reports to create?, Title:="Create Reports", Type:=1) msgbox max End Sub fyi in the code window the set max is all on one line |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
First, it's better to copy directly from the VBE and paste into the body of your
message. Then typos are eliminated (no closing " in the Prompt parm). Dim max As Integer max = Application.InputBox(Prompt:="How many reports to create?", _ Title:="Create Reports ", Type:=1) If max = 0 Then MsgBox "either the user entered 0 or hit cancel" Else MsgBox max End If I like to use application.inputbox with type:=1 when I don't want to bother validating input as a number. It's too easy to let excel/vba do that check. thomas donino wrote: Hello, can some one explain why this doesnt work? Sub test() Dim i as Integer Dim max as Integer Set max = InputBox(Prompt:="How many reports to create?, Title:="Create Reports", Type:=1) msgbox max End Sub fyi in the code window the set max is all on one line -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
ps.
Don't bother using "as integer" or "as single" in your code. Just use: dim Max as long dim AnotherNumber as Double Integers and singles should be forgotten <bg. Dave Peterson wrote: First, it's better to copy directly from the VBE and paste into the body of your message. Then typos are eliminated (no closing " in the Prompt parm). Dim max As Integer max = Application.InputBox(Prompt:="How many reports to create?", _ Title:="Create Reports ", Type:=1) If max = 0 Then MsgBox "either the user entered 0 or hit cancel" Else MsgBox max End If I like to use application.inputbox with type:=1 when I don't want to bother validating input as a number. It's too easy to let excel/vba do that check. thomas donino wrote: Hello, can some one explain why this doesnt work? Sub test() Dim i as Integer Dim max as Integer Set max = InputBox(Prompt:="How many reports to create?, Title:="Create Reports", Type:=1) msgbox max End Sub fyi in the code window the set max is all on one line -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to input pictures automatically based on cell input? | Excel Worksheet Functions | |||
input in number form is being multiplied by 1000 when i input. | Excel Discussion (Misc queries) | |||
Have user input converted to uppercase in same cell as input? | New Users to Excel | |||
=SUMIF(Input!H2:H718,AZ19,Input!E2:E685)AND(IF | Excel Worksheet Functions | |||
CODE to select range based on User Input or Value of Input Field | Excel Programming |