Re: Sample of Visual Basic macros for working with arrays in Excel
For passing and receiving an array in excel, follow the steps given below :
- Open a new workbook.
- Press Alt + F11 to run the Visual Basic Editor.
- On the Insert menu, click Module.
- Type the following code in the module sheet :
Code:
Sub Pass_array ()
Dim myarray As Variant
myarray = Range ( "a1: a10"). Value
receive_array myarray
End Sub
Sub receive_array (thisarray)
For i = 1 To UBound (myarray)
MsgBox myarray (i, 1)
Next
End Sub
- On the File menu, click Close and Return to Microsoft Excel.
- Select Sheet1 and highlight the range A1: A10.
- On the Tools menu, select Macro and then click Macros.
- In the Macro dialog box, click Pass_array, and then click Run.
QTechnology Ultra-Quiet ATX PSU 460W I MSI K8N Neo4-F I AMD Opteron 144 CABNE0545 2.66Ghz I 2 x 512MB RAM I 380GB Maxtor SATAI Raid0 Hard Drive I 40GB Maxtor IDE Hard Drive I Nvidia GeForce 7900GTX I Win XP Home Service Pack 2 I Soundblaster Xtreme Fidelity Fatal1ty I Mercury Home Theater HT-4500
Bookmarks