ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inputbox - Dynamic Array? (https://www.excelbanter.com/excel-programming/314029-inputbox-dynamic-array.html)

ALEX

Inputbox - Dynamic Array?
 
Can I use a input box to load data into a dynamic array?

Example code, if you can please.

THANK YOU!!



--
Jack of all trades... master of none..

Bob Phillips[_6_]

Inputbox - Dynamic Array?
 
something like?

and = Inputbox("input value")
redim preserve aryValues(ubound(aryValues) + 1)
aryValues(ubound(aryValues) + 1) = and

--

HTH

RP

"Alex" wrote in message
...
Can I use a input box to load data into a dynamic array?

Example code, if you can please.

THANK YOU!!



--
Jack of all trades... master of none..




Tom Ogilvy

Inputbox - Dynamic Array?
 
Sub CCCC()
Dim varr()
Dim i as long, j as long, res as variant

res = InputBox("Enter value for 1st element")
i = 0
Do While res < ""
ReDim Preserve varr(0 To i)
varr(UBound(varr)) = res
i = i + 1
res = InputBox("Enter value for " & i + 1 & " element" & _
vbNewLine & " hit cancel to stop entry")
Loop
For j = LBound(varr) To UBound(varr)
Debug.Print j, varr(j)
Next

End Sub

--
Regards,
Tom Ogilvy


"Alex" wrote in message
...
Can I use a input box to load data into a dynamic array?

Example code, if you can please.

THANK YOU!!



--
Jack of all trades... master of none..




ALEX

Inputbox - Dynamic Array?
 
Thanks Tom!!!

One last thing....

How would I call the data in the array?



"Tom Ogilvy" wrote:

Sub CCCC()
Dim varr()
Dim i as long, j as long, res as variant

res = InputBox("Enter value for 1st element")
i = 0
Do While res < ""
ReDim Preserve varr(0 To i)
varr(UBound(varr)) = res
i = i + 1
res = InputBox("Enter value for " & i + 1 & " element" & _
vbNewLine & " hit cancel to stop entry")
Loop
For j = LBound(varr) To UBound(varr)
Debug.Print j, varr(j)
Next

End Sub

--
Regards,
Tom Ogilvy


"Alex" wrote in message
...
Can I use a input box to load data into a dynamic array?

Example code, if you can please.

THANK YOU!!



--
Jack of all trades... master of none..





Tom Ogilvy

Inputbox - Dynamic Array?
 
there was an illustration in the code:

For j = LBound(varr) To UBound(varr)
Debug.Print j, varr(j)
Next

Debug.print goes to the immediate window, so make it visible in the vbe
(View=Immediate Window)

unless you mean something besides looking at the values stored in the array
when you say call the data.

--
Regards,
Tom Ogilvy

"Alex" wrote in message
...
Thanks Tom!!!

One last thing....

How would I call the data in the array?



"Tom Ogilvy" wrote:

Sub CCCC()
Dim varr()
Dim i as long, j as long, res as variant

res = InputBox("Enter value for 1st element")
i = 0
Do While res < ""
ReDim Preserve varr(0 To i)
varr(UBound(varr)) = res
i = i + 1
res = InputBox("Enter value for " & i + 1 & " element" & _
vbNewLine & " hit cancel to stop entry")
Loop
For j = LBound(varr) To UBound(varr)
Debug.Print j, varr(j)
Next

End Sub

--
Regards,
Tom Ogilvy


"Alex" wrote in message
...
Can I use a input box to load data into a dynamic array?

Example code, if you can please.

THANK YOU!!



--
Jack of all trades... master of none..







ALEX

Inputbox - Dynamic Array?
 
Ok, I see. Got it!

Thanks!!

"Tom Ogilvy" wrote:

there was an illustration in the code:

For j = LBound(varr) To UBound(varr)
Debug.Print j, varr(j)
Next

Debug.print goes to the immediate window, so make it visible in the vbe
(View=Immediate Window)

unless you mean something besides looking at the values stored in the array
when you say call the data.

--
Regards,
Tom Ogilvy

"Alex" wrote in message
...
Thanks Tom!!!

One last thing....

How would I call the data in the array?



"Tom Ogilvy" wrote:

Sub CCCC()
Dim varr()
Dim i as long, j as long, res as variant

res = InputBox("Enter value for 1st element")
i = 0
Do While res < ""
ReDim Preserve varr(0 To i)
varr(UBound(varr)) = res
i = i + 1
res = InputBox("Enter value for " & i + 1 & " element" & _
vbNewLine & " hit cancel to stop entry")
Loop
For j = LBound(varr) To UBound(varr)
Debug.Print j, varr(j)
Next

End Sub

--
Regards,
Tom Ogilvy


"Alex" wrote in message
...
Can I use a input box to load data into a dynamic array?

Example code, if you can please.

THANK YOU!!



--
Jack of all trades... master of none..








All times are GMT +1. The time now is 05:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com