VB and VBA Users Source Code: Reading the contents of an Excel Range
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Reading the contents of an Excel Range
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, August 18, 2003
Hits:
2269
Category:
Visual Basic General
Article:
The following code can be used to quickly extact the values of an Excel Range into an array. 'Purpose : Reads the values of a range into an array (much quicker than looping through a range) 'Inputs : rngInput The range to extract the values from. ' avValues See outputs. 'Outputs : Returns the True on success. ' avValues An 2d array containing the values in the range. 'Author : Andrew Baker 'Date : 31/12/2000 13:51 'Notes : 'Revisions : 'Example : Call RangeToArray(Worksheets(1).Range("A1:K1000"), avValues) Function RangeToArray(rngInput As Object, avValues As Variant) As Boolean On Error GoTo ErrFailed avValues = Empty avValues = rngInput.Value RangeToArray = True Exit Function ErrFailed: 'Failed Debug.Print "Error in RangeToArray: " & Err.Description Debug.Assert False RangeToArray = False On Error GoTo 0 End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder