How do you dynamically load an array?
havocdragon wrote:
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
|