+ Reply to Thread
Results 1 to 3 of 3

sumproduct in code

  1. #1
    papa jonah
    Guest

    sumproduct in code

    I am using code to try and populate a table.

    The table looks like

    AA AB
    1
    2 1
    3 2

    I am using code to put a sumproduct in AB2 and AB3 (and further as
    necessary).

    Currently the line of code I am using is:
    cells (r+1, "ab").formula = "=sumproduct((" & causecats.address & "=" &
    _
    cells(r+1, "aa") & ")*(" & cause.columns(3).address & "))"

    When I look at what is showing up in cell AB2, I see:
    =sumproduct(($ah$2:$ah$32=1)*($ak$2:$ak$32))

    The ranges are correct. The problem appears to be that the value, 1,
    in the first array must be in quotes in order to achieve the proper
    result.

    How do I change my code so that the necessary quotes are included?

    Thanks
    Papa J


  2. #2
    Bernie Deitrick
    Guest

    Re: sumproduct in code

    Papa J,

    Cells(r + 1, "ab").Formula = "=sumproduct((" & _
    causecats.Address & "=""" & _
    Cells(r + 1, "aa") & """)*(" & _
    cause.Columns(3).Address & "))"

    HTH,
    Bernie
    MS Excel MVP

    "papa jonah" <adullam04-excelgoogle@yahoo.com> wrote in message
    news:1110996020.090083.58150@l41g2000cwc.googlegroups.com...
    > I am using code to try and populate a table.
    >
    > The table looks like
    >
    > AA AB
    > 1
    > 2 1
    > 3 2
    >
    > I am using code to put a sumproduct in AB2 and AB3 (and further as
    > necessary).
    >
    > Currently the line of code I am using is:
    > cells (r+1, "ab").formula = "=sumproduct((" & causecats.address & "=" &
    > _
    > cells(r+1, "aa") & ")*(" & cause.columns(3).address & "))"
    >
    > When I look at what is showing up in cell AB2, I see:
    > =sumproduct(($ah$2:$ah$32=1)*($ak$2:$ak$32))
    >
    > The ranges are correct. The problem appears to be that the value, 1,
    > in the first array must be in quotes in order to achieve the proper
    > result.
    >
    > How do I change my code so that the necessary quotes are included?
    >
    > Thanks
    > Papa J
    >




  3. #3
    papa jonah
    Guest

    Re: sumproduct in code

    That did thank you


+ 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