I am trying to add numbers from cells if it IsNumeric and for some reason in column K the macro doesnt recognize numbers after row 14?
What am I not seeing?
The range column is "E4:E"
Search criteria is the letter "R" in column "E"
Then using OffSet, I go thru other columns and process data. Most of the macro works except for column K after row 14?
Option Explicit
Dim rShtRange As Range
Dim sShtLastRow As String
Dim vShtCell As Variant
Dim vRuntime As Variant
Dim vRunTotal As Variant
Dim vPartTotal As Variant
Sub TimeSheet()
If Left(ActiveWorkbook.Name, 2) = "TS" Then
With ActiveSheet 'Loop thru Column C
sShtLastRow = .Cells(Rows.Count, "E").End(xlUp).Row
Set rShtRange = .Range("E4:E" & sShtLastRow)
Range("G" & sShtLastRow).Value = ""
Range("F" & sShtLastRow).Value = ""
vRuntime = "0"
vRunTotal = "0"
vPartTotal = "0"
For Each vShtCell In rShtRange
If vShtCell = "R" Then
vRuntime = vRuntime + 1
If vShtCell.Offset(0, 2).Value <> "" Then
vRunTotal = vRunTotal + vShtCell.Offset(0, 2).Value
If IsNumeric(vShtCell.Offset(0, 6).Value) Then
vPartTotal = vPartTotal + vShtCell.Offset(0, 6).Value
MsgBox vPartTotal 'For testing
End If
End If
End If
Next vShtCell
vRuntime = vRuntime - 1
Range("G" & sShtLastRow).Value = vRunTotal
Range("F" & sShtLastRow).Value = ((vRunTotal / vRuntime) * 60) / vPartTotal
End With
End If
End Sub
Bookmarks