Reputation: 1
Hi there im having issues trying to transfer data from an excel spreadsheet to visual basic in the form of an array,any one know any reasonable means of doing so.I have searched online extensively but still cannot find a good tutorial on how to code it.
Simple step by step instructions with explanations would be appreciated as while im familiar with some parts of object orientated programming,I have never transferred data in this way.
Eventually I want to transfer this data onto an object orientated table with a few added buttons and functions thrown in
Cheers for any help guys
Upvotes: 0
Views: 1594
Reputation: 11
The easiest way would be to customise the following code:
examplerange = workbooks("Workbook 1").worksheets("Sheet 1").range("A1:B17")
where Workbook 1
is the name of the workbook that you are using (minus the extension, e.g. '.xlsx'), Sheet 1
is the name of the worksheet the range is located and A1:B17
is the range in which you wish to import.
This creates a Variant
array-which is inefficient-however this is an easy way to import data into VBA and acceptable if you are not working with large sets of data.
Once you're more familiar, you'll be able to separate the elements in the code above and iterate through dynamic ranges as well as being able to import string / integer / boolean arrays to reduce memory usage.
Hope this is what you're looking for.
Upvotes: 1