+ Reply to Thread
Results 1 to 5 of 5

Need VBA code to SumIf criteria is met in another column

Hybrid View

  1. #1
    Registered User
    Join Date
    11-11-2009
    Location
    Alpharetta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Need VBA code to SumIf criteria is met in another column

    I need to SUM the $ Amounts in column B but only include $ Amounts when Column A has "Closed" as the status. Can you help me please? I have been trying for 2 days.

    myLastColumn = .Cells(1, Columns.Count).End(xlToLeft).Column
    myLastRow = .Cells(Rows.Count, 1).End(xlUp).Row

    ReqAmt = Range("N" & Rows.Count).End(xlUp).Row
    If ReqAmt < 2 Then RecAmt = 2
    Range("V2") = Application.WorksheetFunction.SumIf(Range("N2:N" & ReqAmt), "Closed","O2
    Cells(1, myLastColumn + 1).Value = "$ Requested"

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,352

    Re: Need VBA code to SumIf criteria is met in another column

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    I don't quite see the relevance of your code example to the question you are asking.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Need VBA code to SumIf criteria is met in another column

    Hi,

    Try change this line:

    Range("V2") = Application.WorksheetFunction.SumIf(Range("N2:N" & ReqAmt), "Closed","O2
    to

    Range("V2") = Application.WorksheetFunction.SumIf(Range("A2:A" & ReqAmt),"Closed",Range("B2:B" & ReqAmt))
    abousetta
    Last edited by abousetta; 12-07-2011 at 10:12 AM.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Need VBA code to SumIf criteria is met in another column

    Sorry @TMShucks, I didn't see your post until after I posted. Would you like to delete my post?

    abousetta

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,352

    Re: Need VBA code to SumIf criteria is met in another column

    @abousetta: don't worry about it.

+ 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