PAB
12-26-2011, 08:01 PM
Good evening,
I have some code that works perfectly except that one of the output cells "nType(i)" is equal to ZERO and when I try and divide "TotalComb" by "nType(i)" it gives me an ERROR.
What I would like is for it to place a ZERO in the cell and then continue as normal.
The piece of code is between the *******'s
' Display Solution:
For i = 22 To 323
Total = Total + i
Cells(RowCount, "B").Value = "B + A + A + C + D + E + F = " & i
Cells(RowCount, "C").Value = nType(i)
Cells(RowCount, "D").Value = 100 / TotalComb * nType(i)
*******************************************************************
Cells(RowCount, "E").Value = TotalComb / nType(i)
*******************************************************************
Cells(RowCount, "F").Value = "Draws"
' Format Output
Cells(RowCount, "B").HorizontalAlignment = xlLeft
Cells(RowCount, "B").Resize(1, 5).Borders.LineStyle = xlContinuous
Cells(RowCount, "C").NumberFormat = "##,###,##0"
Cells(RowCount, "D").NumberFormat = "##0.00"
Cells(RowCount, "E").NumberFormat = "##,###,##0.00"
Cells(RowCount, "F").HorizontalAlignment = xlRight
RowCount = RowCount + 1
Next i
Thanks in advance,
PAB
I have some code that works perfectly except that one of the output cells "nType(i)" is equal to ZERO and when I try and divide "TotalComb" by "nType(i)" it gives me an ERROR.
What I would like is for it to place a ZERO in the cell and then continue as normal.
The piece of code is between the *******'s
' Display Solution:
For i = 22 To 323
Total = Total + i
Cells(RowCount, "B").Value = "B + A + A + C + D + E + F = " & i
Cells(RowCount, "C").Value = nType(i)
Cells(RowCount, "D").Value = 100 / TotalComb * nType(i)
*******************************************************************
Cells(RowCount, "E").Value = TotalComb / nType(i)
*******************************************************************
Cells(RowCount, "F").Value = "Draws"
' Format Output
Cells(RowCount, "B").HorizontalAlignment = xlLeft
Cells(RowCount, "B").Resize(1, 5).Borders.LineStyle = xlContinuous
Cells(RowCount, "C").NumberFormat = "##,###,##0"
Cells(RowCount, "D").NumberFormat = "##0.00"
Cells(RowCount, "E").NumberFormat = "##,###,##0.00"
Cells(RowCount, "F").HorizontalAlignment = xlRight
RowCount = RowCount + 1
Next i
Thanks in advance,
PAB