Results 1 to 6 of 6

Adding values in cells (stops adding after row 14)

Threaded View

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Adding values in cells (stops adding after row 14)

    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
    Last edited by Rick_Stanich; 10-02-2009 at 09:41 AM.
    Regards

    Rick
    Win10, Office 365

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1