Using Arrays in InputBox Method

V

verizon

Hello Board

I would like the default value of the Input box to be the array: 10,20,40
and of course the user may specify an array of his own.

But I cannot get the Array values to be accepted by this method and I cannot
figure out why:

Dim vAggregations As Variant
vAggregations = Application.InputBox(Prompt:="Enter LB horizons (in
rollovers):", Title:="Lookbacks", Default:=Array("10,20,40"), Type:=64)


If the user wishes to accept the default values, pressing OK on the Dialog
box does nothing. The box remains there apparently still waiting for input.
What am I doing wrong?

Thank you

W
 
T

Tom Ogilvy

Sub tester10()
Dim vAggregations As Variant
vAggregations = Application.InputBox( _
Prompt:="Enter LB horizons (in rollovers):", _
Title:="Lookbacks", Default:="{10,20,40}", _
Type:=64)
Debug.Print vAggregations(1), vAggregations(2), _
vAggregations(3)
End Sub


works for me. The user would need to enter it that way as well {20,50,90}
as an example.

Regards,
Tom Ogilvy
 
V

verizon

Thank you Tom

So it appears that my mistake was that I did not include the brackets {} in
my Default definition?
 
T

Tom Ogilvy

you tried to use a VBA array, but the application.Inputbox works much like a
virtual cell - so apparently it speaks Excel array notation.

Regards,
Tom Ogilvy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top