#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default input box

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default input box

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default input box

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default input box

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default input box

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
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 input pictures automatically based on cell input? bsharp Excel Worksheet Functions 9 May 30th 09 07:16 AM
input in number form is being multiplied by 1000 when i input. jweinograd Excel Discussion (Misc queries) 4 April 16th 07 11:18 PM
Have user input converted to uppercase in same cell as input? Shannonn New Users to Excel 1 June 20th 06 03:19 AM
=SUMIF(Input!H2:H718,AZ19,Input!E2:E685)AND(IF ALex Excel Worksheet Functions 2 March 14th 05 09:19 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


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

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

About Us

"It's about Microsoft Excel"