+ Reply to Thread
Results 1 to 3 of 3

Sum if in VBA

  1. #1
    Baapi
    Guest

    Sum if in VBA

    Dim eRowP As Long
    eRowP = Sheets("Production Log").Cells(Rows.Count, 1).End(xlUp).Row

    Range("H11").Formula = "=SUMPRODUCT(--('Production Log'!$H$5:$H$" & eRowP &
    "=$C11),--('Production Log'!$K$5:$K$" & eRowP & _
    "=H$8),--('Production Log'!$J$5:$J$" & eRowP & "=H$9,1))"

    is giving a 1004 Runtime Error

    your help is highly appriciated
    --
    Thanks,
    Baapi

  2. #2
    Baapi
    Guest

    RE: Sum if in VBA

    and if rewrite the formula as below, it gives an #Value Error in the Excel
    and lemme tell you, all the columns contain text.


    Range("H11").Formula = "=SUMPRODUCT(--('Production Log'!$H$5:$H$" & eRowP &
    "=$C11),--('Production Log'!$K$5:$K$" & eRowP & _
    "=H$8),--('Production Log'!$J$5:$J$" & eRowP & "=H$9,1))"
    --
    Baapi


    "Baapi" wrote:

    > Dim eRowP As Long
    > eRowP = Sheets("Production Log").Cells(Rows.Count, 1).End(xlUp).Row
    >
    > Range("H11").Formula = "=SUMPRODUCT(--('Production Log'!$H$5:$H$" & eRowP &
    > "=$C11),--('Production Log'!$K$5:$K$" & eRowP & _
    > "=H$8),--('Production Log'!$J$5:$J$" & eRowP & "=H$9,1))"
    >
    > is giving a 1004 Runtime Error
    >
    > your help is highly appriciated
    > --
    > Thanks,
    > Baapi


  3. #3
    Dave Peterson
    Guest

    Re: Sum if in VBA

    At the end of your formula, you have:
    "=H$9,1))"

    What's that ,1 (comma one) stuff doing there.

    I found it by changing your code to:
    Range("H11").Formula = "SUMPRODUCT(.....
    (dropped the leading equal sign)

    Then I went back to excel to add the equal sign manually. (Sometimes, it's
    easier to see the problem in the cell--instead of in code.)




    Baapi wrote:
    >
    > and if rewrite the formula as below, it gives an #Value Error in the Excel
    > and lemme tell you, all the columns contain text.
    >
    > Range("H11").Formula = "=SUMPRODUCT(--('Production Log'!$H$5:$H$" & eRowP &
    > "=$C11),--('Production Log'!$K$5:$K$" & eRowP & _
    > "=H$8),--('Production Log'!$J$5:$J$" & eRowP & "=H$9,1))"
    > --
    > Baapi
    >
    > "Baapi" wrote:
    >
    > > Dim eRowP As Long
    > > eRowP = Sheets("Production Log").Cells(Rows.Count, 1).End(xlUp).Row
    > >
    > > Range("H11").Formula = "=SUMPRODUCT(--('Production Log'!$H$5:$H$" & eRowP &
    > > "=$C11),--('Production Log'!$K$5:$K$" & eRowP & _
    > > "=H$8),--('Production Log'!$J$5:$J$" & eRowP & "=H$9,1))"
    > >
    > > is giving a 1004 Runtime Error
    > >
    > > your help is highly appriciated
    > > --
    > > Thanks,
    > > Baapi


    --

    Dave Peterson

+ 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