Thursday, June 27, 2013

How to Transfer Excel VB Data From Range to Array


1. Click the “View” tab on the 'Ribbon' menu. Click the “Macros” icon to display the “Macro” dialog.
2. Select an existing macro name in the list box if you want to add the ability to copy data from a range of cells to an array. Click “Edit” to open the Visual Basic editor. If you want to write a new macro, type the name into the “Macro name” text box and click “Create.'
3. Declare an array variable as a 'Variant' data type. The following example declares the array 'RangeArray':Dim RangeArray As Variant
4. Assign the data cell range to the array. Continuing the example, assign the cells A1 through A10:RangeArray = Range('A1', 'A10')
5. Access the data in the array. To confirm that the example has worked, display the third value in the range with a message dialog:MsgBox RangeArray(3, 1)

Blogger news