I want to get my excel data into a 2D array. For that I did something like this and I want to know the way of getting data to my array.
My requirement is, I want to get all the data in excel file from E12:E140 and U12:U140 to my array. How can I do this?
Thank You
Code:
Private Sub cmdExcel_Click()
Dim oXLApp As Excel.Application 'Declare the object variable
Dim oXLBook As Excel.Workbook
Dim oXLSheet As Excel.Worksheet
Dim Style_no As String
Dim Line_no As String
Dim vArray As Variant
Dim vArray1 As Variant
Dim lngRow As Long
Dim lngRow1 As Long
Dim strTemp As String
Dim sqlqueryVw As String
Dim Operations As ADODB.Recordset
[highlight #FCE94F]Dim Operation(12, 140) As Integer[/highlight]
Set oXLApp = New Excel.Application 'Create a new instance of Excel
'oXLApp.Visible = True 'Show it to the user
Set oXLBook = oXLApp.Workbooks.Open("K:\GENERAL\POD_Infor\295876438.xls") 'Open an existing workbook
Set oXLSheet = oXLBook.Worksheets(1) 'Work with the first worksheet
'*******STYLE NO*****
Style_no = oXLSheet.Range("G5").Value
'*******LINE NO******
Line_no = oXLSheet.Range("G6").Value
'("E12:E140")
'*******JOB NO'S*****
[highlight #FCE94F] Operation = oXLSheet.Range("E12:E140").Value[/highlight]
vArray = oXLSheet.Range("E12:E140").Value
vArray1 = oXLSheet.Range("U12:U140").Value
txtStyleNo.Text = Style_no
txtLine.Text = Line_no
cboOperation.Clear
For lngRow = LBound(vArray, 1) To UBound(vArray, 1)
If Not IsEmpty(vArray(lngRow, 1)) Then
cboOperation.AddItem vArray(lngRow, 1)
End If
Next lngRow
Set oXLBook = Nothing 'Disconnect from Excel (let the user take over)
Set oXLApp = Nothing
Set oXLSheet = Nothing
End Sub
My requirement is, I want to get all the data in excel file from E12:E140 and U12:U140 to my array. How can I do this?
Thank You