Runtime 13 - type mismatch

H

hvfr902

hi,

i am trying to fix a marco that has suddenly broken and the person who
created no longer works for us.
i am getting the type mismatch error on the following line. - any
assistance would be great.

TotalBroke = TotalBroke + Cells(i, 4).Value

the whole module is below

Sub BrokeProductionCalculate()

Dim i As Integer

Dim TotalBroke As Variant

Dim TotalProduction As Variant



Dim intArraySizeY As Integer ' The size of Proficy array
for time specified

Dim strArrayRange As String ' Holds the Excel range of the
Proficy array



Worksheets("PIMS Calc").Activate

'Selects the old range based on the previous array size and clear
the contents.



strArrayRange = "A10:D" & Cells(4, 4).Value + 10

Range(strArrayRange).Select

Selection.ClearContents



' Recalculate cell D2 for updated time period

ActiveSheet.Calculate



' Set array size to the new total number of Proficy data points

intArraySizeY = Cells(4, 4).Value



' Select the new range based on new array size. 4 is added to
intArraySizeY to offset the data in

' the correct place on the spreadsheet.

strArrayRange = "A10:D" & intArraySizeY + 9

Range(strArrayRange).Select



' Create an array with the exact number of Proficy data points.

Selection.FormulaArray = "=PRFTestsData(R4C1,R6C2,R7C2,1,"""",
0,40,""RTIM"",""CODE"",""ESTAT"",""VAL"")"





For i = 10 To (Cells(4, 4).Value + 10)

If Cells(i, 3).Value = "Broke-Cns" Then

TotalBroke = TotalBroke + Cells(i, 4).Value

Else

TotalProduction = TotalProduction + Cells(i, 4).Value

End If



Next i



Worksheets("Sheet1").Cells(12, 4).Value = (TotalBroke +
TotalProduction) / 2204

Worksheets("Sheet1").Cells(14, 4).Value = TotalBroke / 2204

Worksheets("Sheet1").Calculate

Worksheets("Sheet1").Activate

End Sub


Thanks!
 
J

Jim Thomlinson

In sheet PIMS Calc in column 4 (D) look for a value that is not a number.
That would cause the error you describe...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top