+ Reply to Thread
Results 1 to 9 of 9

Using IsNumeric with If and For functions

  1. #1
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Using IsNumeric with If and For functions

    Hello All,

    I'm sure this is very simple but i'm writing to try and further my knowledge. I've found a way to do this with a sumif() formula in the actual worksheet but i like to keep everything in VBA.

    Anyway, I'm trying to sum a column of values, but some of the cells in that column have words and sentences instead of numbers, so i need to sum only the numerical values in the column.

    What i've come up with so far is

    Please Login or Register  to view this content.

    Any help would be greatly appreciated.

    Thank you all,

    DarkF1ame
    Last edited by DarkF1ame; 05-16-2012 at 03:52 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Using IsNumeric with If and For functions

    replace two lines:

    Please Login or Register  to view this content.
    Regards,
    Vandan

  3. #3
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Using IsNumeric with If and For functions

    Thank you,

    I'm still getting a "runtime-error '13' Type Mismatch.

    I don't know why

  4. #4
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Using IsNumeric with If and For functions

    I apologize. I didn't check my code before sending.
    change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Using IsNumeric with If and For functions

    For simplicity, you could use the SUMIF that you have already established.

    Use Application.Worksheetfunction.Sumif(Range("...."),...

    For example:
    Please Login or Register  to view this content.
    This is equivalent to: =SUMIF(B19:B23,B19,C19:C23)


    TIM

  6. #6
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Using IsNumeric with If and For functions

    ^Tim^ I'm trying to make sure the values that return are only numbers, so i don't know how to do that in VBA.

    Ok here is the whole thing and I still am not getting it to work.



    Jobs.xls

  7. #7
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Using IsNumeric with If and For functions

    try this...

    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Using IsNumeric with If and For functions

    You said you had managed to put together a SUMIF formula in the worksheet. I have given you an example of translating that into VBA. I'm sure that would be better than looping through a long list.

    What is the SUMIF formula that you are currently using?

    TIM

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

    Re: Using IsNumeric with If and For functions

    The formula in E367 could be replaced with just =SUM(E2:E361)

    Sum ignores text and numbers stored as text.
    Last edited by shg; 05-16-2012 at 08:39 AM.
    Entia non sunt multiplicanda sine necessitate

+ 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