Consulting

Results 1 to 6 of 6

Thread: Solved: Sumif using named ranges

  1. #1

    Solved: Sumif using named ranges

    Hello everyone!

    I am trying to write code that will sum cells on a condition being met.
    First of all I am three named ranges on a sheet called Summary: CableTotal, WirelessTotal and VOIPTotal all refer to a range.


    On my present sheet I have a select case statement for cells here is my code:
    [VBA]Sub FormatandReportAdditions()
    Dim Endrow As Long
    Dim RowLooper As Long
    Endrow = Cells(65536,3).End(xlUp).Row
    Cells(6, 7).Value = "Total Calls"
    Cells(6, 8).Value = "% Calls Tracked"
    For RowLooper = Endrow To 7 Step -1
    Select Case Cells(RowLooper, 3).Value

    Case Cable
    Cells(RowLooper,7).Formula= "=sumif(ThisWorkbook.Names("CallInventory").refertoRange.value,Cells(RowLoo per,3).Value,ThisWorkbook.Names("CableTotal").RefertoRange.Value)[/VBA]


    Now this is where I get stuck. Should I use an array formula instead?

    Please let me know your thoughts.

  2. #2
    Oh I almost forgot, here is the attachment with a snip of the information. There are over 32K rows!

  3. #3
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    Have you tried this:
    [VBA]Cells(RowLooper,7).FormulaR1C1= "=sumif(CallInventory,RC3,CableTotal)"[/VBA]
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    Just looked at the workbook and there are a couple of things:
    1. You need this:
    [VBA]Case "Cable" [/VBA]
    since Cable is not a variable (as far as I can tell - no code in the workbook)
    2. Your ranges are each defined as two columns for some reason - why?
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5

    Sumif

    There has to be a distinction between French and English that is the only reason. As you can see there are a couple of instances in which French calls are taken in cable , wireless or voip

  6. #6
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    Oh OK.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •