Article ID: 149689
Article Last Modified on 10/10/2006
Sub Sheet_Fill_Array()
Dim myarray As Variant
myarray = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Range("a1:a10").Value = Application.Transpose(myarray)
End Sub
Sub from_sheet_make_array()
Dim thisarray As Variant
thisarray = Range("a1:a10").Value
counter = 1 'looping structure to look at array
While counter <= UBound(thisarray)
MsgBox thisarray(counter, 1)
counter = counter + 1
Wend
End Sub
Sub pass_array()
Dim thisarray As Variant
thisarray = Selection.Value
receive_array (thisarray)
End Sub
Sub receive_array(thisarray)
counter = 1
While counter <= UBound(thisarray)
MsgBox thisarray(counter, 1)
counter = counter + 1
Wend
End Sub
Sub compare_two_array()
Dim thisarray As Variant
Dim thatarray As Variant
thisarray = Range("range1").Value
thatarray = Range("range2").Value
counter = 1
While counter <= UBound(thisarray)
x = thisarray(counter, 1)
y = thatarray(counter, 1)
If x = y Then
MsgBox "yes"
Else MsgBox "nope"
End If
counter = counter + 1
Wend
End Sub
Function array_fill()
array_fill = Application.Transpose(Array(1, 2, 3))
End Function
Function test(x As Object) As Integer
For Each mycell In x
test = test + mycell.Value
Next
End Function
Sub fill_array()
Dim thisarray As Variant
number_of_elements = 3 'number of elements in the array
'must redim below to set size
ReDim thisarray(1 To number_of_elements) As Integer
'resizes this size of the array
counter = 1
fillmeup = 7
For counter = 1 To number_of_elements
thisarray(counter) = fillmeup
Next counter
counter = 1 'this loop shows what was filled in
While counter <= UBound(thisarray)
MsgBox thisarray(counter)
counter = counter + 1
Wend
End Sub
Additional query words: 5.00a 5.00c 8.00 xl97 copy paste visual basic editor XL
Keywords: kbdtacode kbhowto kbprogramming KB149689