Hi, i have been working on best seller report . problem is that user is getting
each week a Trading Excel sheet with more that 50,000 lines and 67 cols .
i have written code to write data from the excel it takes such a long time . approx 2 hour to read only 10 cols data with 50,000 lines from the excel sheet and store in the collection .because after filling into collection.i would like to sort the week sold value in ascending order.keep top 10 value.
and get it at other excel sheet .but it is time consuming process .as schiff suggest me .
excel support direct assignment from excel worksheet to 2d array .and i don't want to touch Excel remote com till it finish writing all the lines in excel sheet .and it seems logical . keeping in 2d variant array so i would like to ask from shiff ."How to transfer an Excel-Cell-Range into a 2D-Variant-array
and perform sorting .because i have been transfer from Excel-cell-range to collection . filling into the
collection is really time consuming .so i would like to fill in the 2d variant array.
and then sort data on the basis of week sold value to get best seller report .
each week a Trading Excel sheet with more that 50,000 lines and 67 cols .
i have written code to write data from the excel it takes such a long time . approx 2 hour to read only 10 cols data with 50,000 lines from the excel sheet and store in the collection .because after filling into collection.i would like to sort the week sold value in ascending order.keep top 10 value.
and get it at other excel sheet .but it is time consuming process .as schiff suggest me .
excel support direct assignment from excel worksheet to 2d array .and i don't want to touch Excel remote com till it finish writing all the lines in excel sheet .and it seems logical . keeping in 2d variant array so i would like to ask from shiff ."How to transfer an Excel-Cell-Range into a 2D-Variant-array
and perform sorting .because i have been transfer from Excel-cell-range to collection . filling into the
collection is really time consuming .so i would like to fill in the 2d variant array.
and then sort data on the basis of week sold value to get best seller report .
Code:
Private Sub BtCreate_Click()
Dim txt As String
Dim RowCount As Long
Dim colCount As Long
Dim oTradingClass As Trading
Dim x As Long
Dim y As Long
If Not Checkinput Then Exit Sub
Set wb = excl.Workbooks.Open(txtSourceFile.Text) ' here we test for the gotten adress
If Not wb Is Nothing Then
excel.Application.Visible = False
Set ws = wb.Worksheets(1)
RowCount = ws.UsedRange.Rows.Count
' colCount = ws.UsedRange.Columns.Count
x = 1
Do
txt = ws.Columns.Cells(x, 1)
If txt = "Barcode" Or txt = "BARCODE" Then Exit Do
x = x + 1
Loop
'next line
x = x + 1
Do
'One or more empty Rows
txt = ws.Columns.Cells(x, 1)
If txt = "" Then
x = x + 1
Else
Exit Do
End If
Loop
y = 1
Do
Set oTradingClass = New Trading
oTradingClass.Key = "K" + CStr(y)
oTradingClass.ItemDesc = ws.Cells(x, 5).Value
oTradingClass.ColorDesc = ws.Cells(x, 7).Value
oTradingClass.DeptName = ws.Cells(x, 11).Value
oTradingClass.WeekSoldQty = ws.Cells(x, 20).Value
oTradingClass.WeekSoldCost = ws.Cells(x, 21).Value
oTradingClass.WeekSoldValue = ws.Cells(x, 22).Value
oTradingClass.PeriodRetail = ws.Cells(x, 37).Value
oTradingClass.WeekCover = ws.Cells(x, 45).Value
oTradingClass.DcStock = ws.Cells(x, 52).Value
oTradingClass.ClosingQty = ws.Cells(x, 54).Value
Call TradingSummaryCol.Add(oTradingClass)
' now next line
x = x + 1
y = y + 1
Loop
Debug.Print TradingSummaryCol.Count
excel.Application.Visible = True
Else
Call MsgBox("Excel is not open", vbInformation, "Test")
End If
End Sub