+ Reply to Thread
Results 1 to 4 of 4

SUMPRODUCT in VBA

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-13-2013
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    152

    SUMPRODUCT in VBA

    Hi,

    I need to convert the below excel function in to VBA

    =SUMPRODUCT(Design!$B$19:$Y$19,'HB Data'!C3:Z3)
    I have tried the below code but it shows 'Application-defined or Object-defined error'

    LastCol = Cells(1502, Columns.Count).End(xlToLeft).Column
    na = Split(Cells(1502, LastCol).Address, "$")(1) ''' o/p is 'Y"
    LastCola = Cells(3, Columns.Count).End(xlToLeft).Column
    nas = Split(Cells(j, LastCola).Address, "$")(1) ''' o/p is 'Z"
    j=3
    For i = 1 To Total_products
    Cells(1, 1).Value = "=SUMPRODUCT(Design!B18 +" & i & ":" & na & "18 +" & i & ",'HB Data'!C3" & ":" & nas & j & ")"
    Next i
    Kindly help me to get out of this.

    Thanks
    Last edited by gan_xl; 03-05-2014 at 10:31 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: SUMPRODUCT in VBA

    you can not SUM that way.

    Try something like:

    Cells(1, 1).Value = "=SUMPRODUCT(Design!B" 18 + i & ":" & na & 18 + i & ",'HB Data'!C3:" & nas & j & ")""

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: SUMPRODUCT in VBA

    WorksheetFunction.SumProduct(Sheets("Design").Range("$B$19:$Y$19"), Sheets("HB Data").Range("C3:Z3"))
    ?

  4. #4
    Forum Contributor
    Join Date
    03-13-2013
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    152

    Re: SUMPRODUCT in VBA

    Thank you both. It works perfectly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 05-19-2012, 02:54 AM
  2. Replies: 5
    Last Post: 04-20-2012, 08:54 AM
  3. Replies: 6
    Last Post: 03-09-2011, 08:01 AM
  4. Subtract Sumproduct from a sumproduct
    By Prcntrygrl in forum Excel General
    Replies: 6
    Last Post: 01-17-2011, 02:34 PM
  5. Using a SumProduct Count to find a SumProduct Total?
    By XL021710 in forum Excel General
    Replies: 3
    Last Post: 02-18-2010, 08:31 AM

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