Hi
I hope this code helps, what it does is to put an Excel Range into a Strings Array in VB.
The code is not very good since i dont remember if there's a way to asign a range into an array without a FOR (but you can find it out in some forum... yeah right...)
- Sub Hola()
-
Dim i As Long
-
Dim j As Integer
-
Dim MaxRow As Long
-
Dim MaxCol As Integer
-
Dim Obj1 As Object
-
Dim mStr1() As String
-
-
MaxRow = 10
-
MaxCol = 10
-
-
ReDim mStr1(MaxRow, MaxCol) As String
-
With Application.FileDialog(msoFileDialogFilePicker)
-
.AllowMultiSelect = True
-
.Filters.Clear
-
.Filters.Add "Excel Files (*.xls)", "*.xls"
-
.Show
-
If .SelectedItems.Count > 0 Then
-
Set Obj1 = CreateObject("excel.application")
-
Obj1.Workbooks.Open (.SelectedItems.Item(1))
-
End If
-
End With
-
For i = 1 To MaxRow
-
For j = 1 To MaxCol
-
mStr1(i, j) = Obj1.Worksheets(1).Cells(i, j)
-
Next
-
Next
-
End Sub
oh, by the way, you can add a line to see the excel worksheet and then close it or something like :
obj1.visible=true
or
obj1.activeworkbook.close savechanges:=false
Good Luck!