View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default how do I extract data from worksheet to VBA?

On Fri, 31 Jul 2009 13:20:01 -0700, Bob Allen
wrote:

How do I extract a range of data into a VBA array?



Here's a simple method:

Option Explicit
Sub GetArray()
Dim rg As Range
Dim a As Variant
Set rg = Range("A1:D10")
a = rg.Value
End Sub

a will turn into a 2D array, with each element containing the value in one of
the cells in rg.

a : Variant/Variant(1 to 10, 1 to 4)
--ron