Consulting

Results 1 to 9 of 9

Thread: Sumproduct instead of countif. 1 digit numbers problem.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    SUMPRODUCT will do it

    =SUMPRODUCT(--(MID(A1:A10,2,1)="6"))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  2. #2
    VBAX Newbie
    Joined
    Aug 2013
    Posts
    4
    Location
    Quote Originally Posted by xld View Post
    SUMPRODUCT will do it

    =SUMPRODUCT(--(MID(A1:A10,2,1)="6"))
    Ha! I was wondering if there is a simple formula Thanks, xld!
    Quick question though, how can I replace this "6" (with the quotes) with a cell reference?
    If I've got 6 in the B6 cell for example,
    =SUMPRODUCT(--(MID(A1:A10,2,1)=B6)) won't work

  3. #3
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    I have to admit, this is awesome I have never used VBA before, but your step by step guide is foolproof.
    Thank you so much, it works great!
    I wish I understood the code itself, but it's a different matter, VBA is on to-do list.
    Thanks again, SamT, you saved my dissertation.
    In VBA, Place the Keyboard cursor inside a word and press F1 for help on that word.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    VBAX Newbie
    Joined
    Aug 2013
    Posts
    4
    Location
    Quote Originally Posted by fleskj View Post
    Ha! I was wondering if there is a simple formula Thanks, xld!
    Quick question though, how can I replace this "6" (with the quotes) with a cell reference?
    If I've got 6 in the B6 cell for example,
    =SUMPRODUCT(--(MID(A1:A10,2,1)=B6)) won't work
    I've figured it out,
    it should be
    =SUMPRODUCT(--(MID(A1:A10,2,1)+0=B6)) for it to work

    EDIT: scratch that, it leaves me with the original problem of 1 digit cells, nevermind

    Quote Originally Posted by SamT View Post
    In VBA, Place the Keyboard cursor inside a word and press F1 for help on that word.
    Thanks! I'll look into that.
    Last edited by fleskj; 08-09-2013 at 09:55 AM.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    It doesn't work for the same reason that your original formula doesn't work, you are comparing numeric items with strings. You need to string it

    =SUMPRODUCT(--(MID(A1:A10,2,1)=TEXT(B6,"General")))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Tags for this Thread

Posting Permissions

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