Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Waldemar Fischer   on Oct 15 In MS Office Category.

  
Question Answered By: Grant Jones   on Oct 15

I'm not totally clear on what you are asking, but perhaps these
examples will help. Step through these using F8 while looking at the
View-Locals Window to see what is going on. Be sure to define MyList
and MySum as named ranges in your sheet.


Sub Example1()
A = Range("MyList")
'A becomes a 2 dimensional array
'access elements by A(row, column)
s = 0
NRows = UBound(A, 1)
For r = 1 To NRows
s = s + A(r, 1)
Next
Range("MySum") = s
End Sub

Sub Example2()
s = 0
For Each c In Range("MyList")
s = s + c
Next
Range("MySum") = s
End Sub

Share: 

 
 
Didn't find what you were looking for? Find more on VBA Array - return value to a cell Or get search suggestion and latest updates.


Tagged: