+ Reply to Thread
Results 1 to 6 of 6

Adding values in cells (stops adding after row 14)

  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?

    Please Login or Register  to view this content.
    Last edited by Rick_Stanich; 10-02-2009 at 09:41 AM.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Adding values in cells (stops adding after row 14)

    First, if you're adding numbers, why declare the variables that accumulated them as Variants instead of Doubles?

    Second, why initialize them to strings?
    Please Login or Register  to view this content.
    Third, do the cells to be added in col K contain numbers stored as strings, or just numbers? If the latter, why not use Vartype(.Value) instead of IsNumeric(.Value), to know which are numbers (to be added) versus anything else (not to be added)?
    Entia non sunt multiplicanda sine necessitate

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

    Re: Adding values in cells (stops adding after row 14)

    Quote Originally Posted by shg View Post
    First, if you're adding numbers, why declare the variables that accumulated them as Variants instead of Doubles?

    Second, why initialize them to strings?
    Please Login or Register  to view this content.
    Third, do the cells to be added in col K contain numbers stored as strings, or just numbers? If the latter, why not use Vartype(.Value) instead of IsNumeric(.Value), to know which are numbers (to be added) versus anything else (not to be added)?
    First, Because I didn't know any better, but I do now.

    Second, If I dont the variable continues to add, doubling the values everytime I run the macro.

    Third, I will read up on this one.
    Last edited by Rick_Stanich; 10-02-2009 at 09:41 AM.

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

    Re: Adding values in cells (stops adding after row 14)

    Using VarType didnt make a difference.
    Please Login or Register  to view this content.
    I am going to try testing the cell for what is in it.

    Edit:
    I used the wrong constant, changed to vbDouble
    Please Login or Register  to view this content.
    Still doesn't add after row 14 and I believe the code above is the only portion that isn't adding the cell value after row 14?

    With the code as follows, the first MsgBox shows a value of "5" for the numeric (vbDouble) VarType and an "8" for text. It also reads past row 14. The second MsgBox doesn't add the value after row 14.

    I am attaching a workbook if any can take the time to look at it.
    Attached Files Attached Files
    Last edited by Rick_Stanich; 10-02-2009 at 09:26 AM.

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

    Re: Adding values in cells (stops adding after row 14)

    I figured it out. How silly.
    This portion of code;
    Please Login or Register  to view this content.
    is finding a blank cell in G16, so processing stops and K16 cell is not read by the macro. Adding at least a Zero ("0") value to cell G16 allows the macro to process through the remaining cells as I intended.

    Thanks to all who looked and or offered advice.
    Last edited by Rick_Stanich; 10-02-2009 at 09:40 AM.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,979

    Re: Adding values in cells (stops adding after row 14)

    This line is preventing row 16 from being included:
    Please Login or Register  to view this content.
    Edit: should have refreshed!
    Everyone who confuses correlation and causation ends up dead.

+ Reply to Thread

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