+ Reply to Thread
Results 1 to 9 of 9

SUM column variable criteria

  1. #1
    Registered User
    Join Date
    07-22-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003, 2010
    Posts
    21

    SUM column variable criteria

    Hi everyone,

    I know this title seems too easy for some of you, but i couldn't made it! i kindly eed your help to solve it, plz!

    I'll attach my excel file to this post, here is my pb:
    Column A (Week) and Column B (Product) both criteria i need to select to Sum up only visible value from the column C (at the end of the column), and on the same method do it for column G (NOK).

    I tried SUMIFS(...), Index(... Match(...)), VLOOKUP().
    it doesn't work, i don't know why. But the columns A to H generate from another excel file, so lenth of the colmn can be 600 or more than 10000.

    SO i want to do in macro here what i have done:

    Please Login or Register  to view this content.
    xl.jpgBook2.xls

    if someone make this macro more light n appicable, i'll be very glad!

    Thank you.
    Last edited by jeffreybrown; 08-05-2013 at 06:24 PM. Reason: As per Forum Rule #3, please use code tags…Thanks.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: SUM column variable criteria

    celv and celv1 aren't named ranges. If the Range you are trying to select is the info held in those string variables then remove the "".
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    07-22-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003, 2010
    Posts
    21

    Re: SUM column variable criteria

    @ XeRo Solus, Thanks , i tried Range(celv) without "" , it's still not working!
    What should i named the variables "celv" and "celv1"?

    in the file i attached, the macro is inside, so in this post, the progrm is for a overall view!
    But i nw i added the [CODE], [\CODE]! guess it should ok, now!

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: SUM column variable criteria

    Well those names are fine. There are a couple undefined variables and some selection where there doesn't have to be, so first lets try to establish exactly what you're trying to achieve.

    According to you thread title you'd like to sum based on a criteria, are you copy and pasting to remove formulas?

  5. #5
    Registered User
    Join Date
    04-05-2013
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: SUM column variable criteria

    Hello,

    Please see attached image and do the needful.

    I need SUMIFS formula for multiple criteria in a particular selected range.

    Thank you all in advance.SUMIFS formula for multiple criterias in slected range...jpg

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: SUM column variable criteria

    Alliswell, welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: SUM column variable criteria

    Alliswellandwell
    Please read the forum rules.
    In your case, pay attention to #2.

    http://www.excelforum.com/forum-rule...rum-rules.html

    OK, FDibbins was faster.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: SUM column variable criteria

    DJ, I dont quite understand what you are trying to sum on the table on the right? I can do a sum based on the week, and can probably do a sum based on...
    Sum N.iO
    Sum checked
    PPM
    IF i knew where they were lol

  9. #9
    Registered User
    Join Date
    07-22-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003, 2010
    Posts
    21

    Re: SUM column variable criteria

    hello guys, sorry for the late reply.
    This code is working:

    [CODE]
    Sub SumUp()
    Dim celv As Range
    Dim celv1 As Range
    Dim i As Integer
    Dim k As Integer

    With Sheets("Sheet1")
    .AutoFilterMode = False
    On Error Resume Next

    'For Each celv In Range("L4:V10")

    'For Each celv1 In Range("L5:V11")

    For i = 12 To 22 Step 1
    For k = 4 To 10 Step 3
    Set celv = Cells(k, i).Value
    Set celv1 = Cells(k + 1, i).Value
    With Sheets("Sheet1").Range("A1:H1")
    .AutoFilter
    .AutoFilter Field:=1, Criteria1:=Worksheets("Sheet1").Cells(3, i + 1).Value
    .AutoFilter Field:=2, Criteria1:=Worksheets("Sheet1").Cells(k, "J").Value

    End With

    Dim Lr As Long

    Lr = .Range("G" & Rows.Count).End(xlUp).Row
    Range("L14").Value = WorksheetFunction.Subtotal(9, .Range("G2:G" & Lr))

    Range("L14").Select
    Selection.Copy
    celv.Select
    ActiveSheet.Paste
    Cells(k, i + 1).Value = celv


    Lr = .Range("C" & Rows.Count).End(xlUp).Row
    Range("L15").Value = WorksheetFunction.Subtotal(9, .Range("C2:C" & Lr))
    Range("L15").Select
    Selection.Copy
    celv1.Select
    ActiveSheet.Paste
    Cells(k + 1, i + 1).Value = celv1

    .Range("L14").Clear
    .Range("L4").Clear
    .Range("L15").Clear
    .Range("L5").Clear
    .AutoFilterMode = False

    Next k
    Next i
    'Next celv1
    'Next celv
    On Error GoTo 0

    End With
    End Sub

    [\CODE]


    Thank you!

+ 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. [SOLVED] Sum column based on variable start and variable end months
    By Steve N. in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-06-2013, 08:01 PM
  2. Replies: 1
    Last Post: 10-27-2012, 02:54 AM
  3. Replies: 6
    Last Post: 04-14-2012, 04:07 AM
  4. Replies: 4
    Last Post: 01-14-2011, 09:30 PM
  5. Assigning a variable and pasting variable to last unused column.
    By Ageia in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-20-2008, 05:06 PM

Tags for this Thread

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