Login | |
|
 |
RE: excel to array, perform functions to convert units ... - 7/1/2008 4:35:15 AM
|
|
 |
|
| |
ehvbs
Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
line 61 objSheet.Cells(iRow, [CS UOM ] ).Value = "EA" line 129 objSheet.Cells(iRow, [CS UOM ] ).Value = "GA" line 176 objSheet.Cells(iRow, [CS UOM ] ).Value = "LB" line 238 objSheet.Cells(iRow, [CS UOM ] ).Value = "TK" ===> subroutine approach: you would have to correct it just once run time error line 184 objSheet.Cells(iRow, [CS Package SOH Qty]).Value = objSheet.Cells(iRow, [CS Amount(soh)]).Value / objSheet.Cells(iRow, [CS Measure]).Value looks like objSheet.Cells(iRow, [CS Measure]).Value is 0. How can that be? Ad hoc remedy: If 0 = objSheet.Cells(iRow, [CS Measure]).Value Then WScript.Echo iRow, "LB-NULL", "objSheet.Cells(iRow, [CS Measure]).Value == 0" Else objSheet.Cells(iRow, [CS Package SOH Qty]).Value = objSheet.Cells(iRow, [CS Amount(soh)]).Value / objSheet.Cells(iRow, [CS Measure]).Value End If Output: 202 LB-NULL objSheet.Cells(iRow, [CS Measure]).Value == 0 203 LB-NULL objSheet.Cells(iRow, [CS Measure]).Value == 0 204 LB-NULL objSheet.Cells(iRow, [CS Measure]).Value == 0 205 LB-NULL objSheet.Cells(iRow, [CS Measure]).Value == 0 next rt error line 68: objSheet.Cells(iRow, [CS Package SOH Qty]).Value = objSheet.Cells(iRow, [CS Amount(soh)]).Value / objSheet.Cells(iRow, [CS Measure]).Value looks similar; same remedy? If we had this kind of action in a sub, we would be done after the first correction ....
|
|
| |
|
|
|
 |
RE: excel to array, perform functions to convert units ... - 7/1/2008 4:57:43 AM
|
|
 |
|
| |
ehvbs
Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
Of course the error message code should be WScript.Echo iRow, sUpdType, "objSheet.Cells(iRow, [CS Measure]).Value == 0" instead of WScript.Echo iRow, "LB-NULL", "objSheet.Cells(iRow, [CS Measure]).Value == 0" WScript.Echo iRow, "TK-NULL", "objSheet.Cells(iRow, [CS Measure]).Value == 0" ...
|
|
| |
|
|
|
 |
RE: excel to array, perform functions to convert units ... - 7/1/2008 5:19:50 AM
|
|
 |
|
| |
ehvbs
Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
totals: I added (1) two cols to my sheet () (2) the consts Const [Recno] = 31 Const [RunTotal] = 32 Const [RunTotal1] = 33 Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" ) (3) the init: Dim nRecs : nRecs = 0 Dim dblRunTotal : dblRunTotal = 0.0 Dim dblRunTotal1 : dblRunTotal1 = 0.0 Do Until "" = objSheet.Cells( iRow, [Old-Prod-Code] ) (4) The calculations: End Select dblRunTotal = dblRunTotal + objSheet.Cells( iRow, [Total] ) dblRunTotal1 = dblRunTotal1 + objSheet.Cells( iRow, [Total1] ) objSheet.Cells( iRow, [RunTotal] ) = dblRunTotal objSheet.Cells( iRow, [RunTotal1] ) = dblRunTotal1 iRow = iRow + 1 nRecs = nRecs + 1 Loop (5) the output: WScript.Echo "Totals", dblRunTotal, dblRunTotal1 WScript.Echo "iRow", iRow, "nRecs", nRecs, "Secs", Fix( Timer() - tStart) oWBook.Saveas oFS.GetAbsolutePathName( ".\out06.xls" ) and got: ... lots of "can't divide by zero' diagnostics 3055 LB-NULL objSheet.Cells(iRow, [CS Measure]).Value == 0 3056 EA-NULL objSheet.Cells(iRow, [CS Measure]).Value == 0 3057 EA-NULL objSheet.Cells(iRow, [CS Measure]).Value == 0 3058 EA-NULL objSheet.Cells(iRow, [CS Measure]).Value == 0 3059 LB-NULL objSheet.Cells(iRow, [CS Measure]).Value == 0 Totals 10661984,3104146 10661984,3104146 iRow 3060 nRecs 3058 Secs 176 and two completely filled cols AF and AG in my output .xls
|
|
| |
|
|
|
|