You don't say how the code doesn't work but try this.
Sub CalcLengths()
Dim lastrow As Long

    lastrow = Cells(Rows.Count, "F").End(xlUp).Row

    With Range("G2:G" & lastrow)
        .FormulaR1C1 = "=RC[-5]*1"
        .NumberFormat = "h:mm"
    End With

End Sub