hey guys I ran this code and I kept getting a message of
Runtime Error '13':
Type Mismatch
What does that mean, this is the code I ran and when I click on debug the red font is highlighted. Is there something wrong with it?
Sub AverageWindSpeed()
Dim i, LastRow, eTime, wSpeed
'set last used row for including additonal rows, if added
LastRow = Range("E" & Rows.count).End(xlUp).row
'begin in row2 as etime refers to prior row. There is no row prior than row 1
For i = 2 To LastRow
'calculate the elapsed time. Subtracting the cells returns a decimal value of a day.
'Multiply by 24 to return hours.
eTime = eTime + (Cells(i, "E").Value - Cells(i - 1, "E").Value) * 24
'calculate the accumulated total wind speed by adding each increment to the accumulated total
wSpeed = wSpeed + ((Cells(i, "E").Value - Cells(i - 1, "E").Value) * 24) * (Cells(i - 1, "F").Value)
'loop
Next
'set average wind speed in cell B13
Range("B13").Value = Round(wSpeed / eTime, 2)
End Sub
Thanks helps
Runtime Error '13':
Type Mismatch
What does that mean, this is the code I ran and when I click on debug the red font is highlighted. Is there something wrong with it?
Sub AverageWindSpeed()
Dim i, LastRow, eTime, wSpeed
'set last used row for including additonal rows, if added
LastRow = Range("E" & Rows.count).End(xlUp).row
'begin in row2 as etime refers to prior row. There is no row prior than row 1
For i = 2 To LastRow
'calculate the elapsed time. Subtracting the cells returns a decimal value of a day.
'Multiply by 24 to return hours.
eTime = eTime + (Cells(i, "E").Value - Cells(i - 1, "E").Value) * 24
'calculate the accumulated total wind speed by adding each increment to the accumulated total
wSpeed = wSpeed + ((Cells(i, "E").Value - Cells(i - 1, "E").Value) * 24) * (Cells(i - 1, "F").Value)
'loop
Next
'set average wind speed in cell B13
Range("B13").Value = Round(wSpeed / eTime, 2)
End Sub
Thanks helps