+ Reply to Thread
Results 1 to 3 of 3

WorksheetFunction SumIfs across a range of cells - not working

  1. #1
    Registered User
    Join Date
    06-24-2011
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    WorksheetFunction SumIfs across a range of cells - not working

    Hi all,

    I'm trying to do what (I think, at least) is a simple VBA function in Excel.
    I have two ranges that I have defined via VBA user input, and I am trying to create a SUMIFS function in VBA that functions the same as if you entered it into Excel and "dragged" the formula over.

    The range of cells that determine the outcome of the SUMIFS are B7:K7, and I want the output to be written to B30:K30.
    My current code that creates a "run-time error '13: Type mismatch" is below:

    Range("B30:K30").Select
    Range("B30:K30") = Application.WorksheetFunction.SumIfs(inventoryDollarsRange, inventoryGLCodeRange, Range("B7:K7"))


    When I set the formula to only use one cell (e.g. "B7" and "B30") it works perfectly.

    Any help would be most appreciated.


    Thank you!

  2. #2
    Registered User
    Join Date
    06-24-2011
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: WorksheetFunction SumIfs across a range of cells - not working

    Nevermind - Got it!

    Dim i As Variant
    For i = 2 To 10

    Cells(30, i) = Application.WorksheetFunction.SumIfs(inventoryDollarsRange, inventoryGLCodeRange, Cells(7, i))

    Next i
    Exit Sub

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: WorksheetFunction SumIfs across a range of cells - not working

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    EDIT: Nevermind
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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. sumifs vs. Application.WorksheetFunction.SumIfs
    By flooyd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-01-2016, 11:22 AM
  2. [SOLVED] WorksheetFunction SumIfs With Multiple Criteria
    By Harry Basra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-25-2016, 08:32 AM
  3. [SOLVED] WorksheetFunction.SumIfs + Variable
    By VitoBdG in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-08-2016, 10:21 AM
  4. [SOLVED] Application.worksheetfunction.sumifs on large dataset
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-01-2013, 08:22 PM
  5. Running a WorksheetFunction on a Range of Cells and returning results in 2nd Range
    By excelforum123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2013, 12:23 PM
  6. How to use > in WorksheetFunction.Sumifs
    By davidman1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-02-2013, 10:40 AM
  7. [SOLVED] Sumifs for two date range not working
    By SheetalGanesh in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-12-2012, 04:56 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