Hi
1) Subscript out of range may be becos u are referring to a non existent column. U make a reference to column 13 so u must have Msflexgrid1.Cols = 14 (which is 0 to 13)
2) I dont know ur loaded data but are u sure that ur exponential formula do not produce crazily high numbers.
3) I see where ur recursion error is.
In loop 3, column 1 is dependant on the value in col 4
In loop 5, column 4 is dependant on the value in col 1
eg
4) Also, the code is getting a bit messy becos of all the val's formats etc so i added a function to reduce the codeVB Code:
[b].TextMatrix(x, 1)[/b] = Format$((2.4 * Val([b].TextMatrix(x, 4)[/b]) _ ^ Val(.TextMatrix(x, 11)) * Val(.TextMatrix(x, 8))), "0.00") [b].TextMatrix(x, 4)[/b] = Format$((.TextMatrix(x, 2)) * Val([b].TextMatrix(x, 1)[/b]), "0.00")
That code still includes the recursion error but i am afraid that that error is up to you becos only u know what answers u want in each column.VB Code:
Private Sub Command1_Click() With MSFlexGrid1 .Redraw = False For x = 1 To .Rows - 1 ' start from row 1 since row 0 is headings .TextMatrix(x, 5) = Format$(TVal(x, 9) * 6.5 + 0.1 * TVal(x, 10), "0.00") .TextMatrix(x, 3) = Format$(TVal(x, 5) * TVal(x, 13) / 1000, "0.00") .TextMatrix(x, 1) = Format$(2.4 * TVal(x, 4) ^ TVal(x, 11) * TVal(x, 8), "0.00") .TextMatrix(x, 0) = Format$(2.5 * TVal(x, 1) ^ TVal(x, 12), "0.00") .TextMatrix(x, 4) = Format$(TVal(x, 2) * TVal(x, 1), "0.00") Next .Redraw = True End With End Sub Private Function TVal(llngRow As Long, llngCol As Long) As Double TVal = Val(MSFlexGrid1.TextMatrix(llngRow, llngCol)) End Function
Regards
Stuart




Reply With Quote