How do you dynamically load an array?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all. Over the last month or so, I have familliarized myself (almost
painfully so) with utilizing arrays and loops together in my macros for
efficiency (and sanity).

What I am wondering, is how do you load an array dynamically?

I know well how to declare one such as

V = Array("stuff","morestuff") etc etc
However what if the contents of the array need to change on a weeky basis? I
hate having to go in and reprogram it, and was wondering if there was a way
to load it dynamically?
 
Maybe soimething like

ReDim Preserve ary(UBound(ary) + 1)
ary(UBound(ary)) = "xyz"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
havocdragon said:
Hi all. Over the last month or so, I have familliarized myself (almost
painfully so) with utilizing arrays and loops together in my macros for
efficiency (and sanity).

What I am wondering, is how do you load an array dynamically?

I know well how to declare one such as

V = Array("stuff","morestuff") etc etc
However what if the contents of the array need to change on a weeky basis? I
hate having to go in and reprogram it, and was wondering if there was a way
to load it dynamically?

You may want to declare the array as opposed to using the array
function. Without clarification it is unclear what you want to do. Here
is a sub that loads an array with the weeks dates starting with today.

Sub ldarray()
Dim myarray(1 To 7) As Variant
Dim c As Variant
Dim i As Integer

c = Now()
For i = 0 To 6
myarray(i + 1) = Format(c + i, "mm/dd/yyyy")
Next


End Sub
 

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

Back
Top