+ Reply to Thread
Results 1 to 7 of 7

Trying to get Indirect to ignore blank cells.

  1. #1
    Registered User
    Join Date
    03-31-2021
    Location
    Spokane
    MS-Off Ver
    2010
    Posts
    3

    Unhappy Trying to get Indirect to ignore blank cells.

    Hi
    I'm trying to make an equation that will pull data across multiple worksheets and return the average of these numbers based on month. I finally figured the equation out, but the issue now is I get a #ref error when I try to ask it to look at pages that do not yet exist.
    This is the equation:
    =SUMPRODUCT(SUMIFS(INDIRECT("'"&A8:A28&"'!N8:N15"),INDIRECT("'"&A8:A28&"'!C8:C15"),">="&DATE(2021,1,1),INDIRECT("'"&A8:A28&"'!C8:C15"),"<="&DATE(2021,1,31))/SUMPRODUCT(COUNTIFS(INDIRECT("'"&A8:A28&"'!C8:C15"),">="&DATE(2021,1,1),INDIRECT("'"&A8:A28&"'!C8:C15"),"<="&DATE(2021,1,31))))

    There are worksheets connected with cells A8-A10, but I will be adding more worksheets as time goes on, so I'd like to have an equation that I don't have to edit every time a new sheet is added.

  2. #2
    Registered User
    Join Date
    03-28-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    11

    Re: Trying to get Indirect to ignore blank cells.

    You could surround the formular with IFERROR()

    i.e. =IFERROR(SUMPRODUCT(SUMIFS(INDIRECT("'"&A8:A28&"'!N8:N15"),INDIRECT("'"&A8:A28&"'!C8:C15"),">="&DATE(2021,1,1),INDIRECT("'"&A8:A28&"'!C8:C15"),"<="&DATE(2021,1,31))/SUMPRODUCT(COUNTIFS(INDIRECT("'"&A8:A28&"'!C8:C15"),">="&DATE(2021,1,1),INDIRECT("'"&A8:A28&"'!C8:C15"),"<="&DATE(2021,1,31)))),"")

    this will replace the #ref error with a blank.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Trying to get Indirect to ignore blank cells.

    I would use a Named Range, instead of A8:A10 (or A8:A28)???

    With the cursor in the sheet where the big formula is... CTRL F3. New. Call it Range

    use this formula:

    =$A$8:INDEX($A:$A,AGGREGATE(14,6,MATCH({1E+100,"Zzzz"},$A:$A),1))

    Then in your formula, replace A8:A28 with Range
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Registered User
    Join Date
    03-31-2021
    Location
    Spokane
    MS-Off Ver
    2010
    Posts
    3

    Re: Trying to get Indirect to ignore blank cells.

    I need it to present the current averages instead of a blank

  5. #5
    Registered User
    Join Date
    03-31-2021
    Location
    Spokane
    MS-Off Ver
    2010
    Posts
    3

    Re: Trying to get Indirect to ignore blank cells.

    Hi! Sorry I don't think I have my shortcuts set up. Is there a different way to access this besides ctrl F3?

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Trying to get Indirect to ignore blank cells.

    Post a sample sheet and I will set it up. If you are on a Mac... accessing the Name Manager lay have a different shortcut.

  7. #7
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Trying to get Indirect to ignore blank cells.

    If you'd have a lot (hundreds or more) of this sort of formula, recalculation could slow down noticeably. There are alternatives.

    One would be to use a new worksheet as a master table pulling in data from other worksheets. Add a new worksheet named Gather.

    The following uses XLM functions. Those can't be used directly in cell formulas, but they can be used in defined names. So define the following names using the following formulas.

    WBNAME
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    WSNAMES
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    WBNAME evaluates to the name of the workbook in which its defined, and WSNAMES evaluates to an array of the sheet names in that workbook. The IF(Gather!$A$1,1,1) allows WSNAMES to be volatile or not. If Gather!A1 contained the formula =NOW(), WSNAMES would recalculate whenever anything triggers recalculation. If Gather!A1 were blank, renaming existing worksheets wouldn't recalculate WSNAMES, but inserting or deleting worksheets would recalculate WSNAMES.

    With the names of your worksheets of interest in Gather!A:A beginning in cell A2, add formulas in column B like

    B2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    which will return integers when the name in A2 appears in WSNAMES, #N/A otherwise.

    Then add formulas in column C and right as

    C2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    D2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Copy E2:F2 and paste into E1:F1. Select E2:F2 and fill down to match the entries in column A and formulas in column B. The formulas from cell C2 right and down should produce TEXT which looks like formulas.

    With the range from C2 right and down still selected, copy, and paste special on top of itself as values. This converts formulas returning text which looks like formulas into text constants which look like formulas. Then press [Ctrl]+H to display the Find and Replace dialog, find = and replace with = in all instances in the selected range. Yes, replace = with itself. This has the effect of entering all these text constants as formulas. Excel will prompt you to open workbooks for each worksheet name in column A which doesn't exist, but you could just hold down [Esc] until all cells have been processed.

    You wind up with a table of formulas for numerators in column C and denominators in column D. The numbers will be actual values from worksheets names in column A which exist and 0s for names which don't exist.

    With a formula like =NOW() in Gather!A1, as you add worksheets and give them names appearing in Gather!A:A, the formulas in this table will recalculate to include those worksheets since WSNAMES would recalculate with every worksheet name change. Once you've added all worksheets with names in Gather!A:A, you could clear Gather!A1, making WSNAMES nonvolatile and speeding recalculation. At that point, deleting worksheets would recalculate WSNAMES.

    Your final formula would then be something like

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If the worksheets of interest could be in sequential order in the workbook, the other usual approach for this sort of thing is using bracketing blank worksheets with indicative names like alpha and omega immediately before and after the worksheets of interest along with VBA user-defined functions returning arrays from ranges across those worksheets excluding the bracketing worksheets. Given such alpha and omega worksheets,

    Please Login or Register  to view this content.
    Use this in formulas like

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    which is longer than your formula using INDIRECT, but it isn't volatile. You could shorten it using cells containing the formulas for midpoint of and range between the dates. Or return the get3D calls to ranges, and use those ranges in SUMIFS and COUNTIFS calls.

    Finally, if you believe you really must use INDIRECT, try

    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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: 2
    Last Post: 08-13-2018, 02:30 AM
  2. [SOLVED] how to count cells with values but ignore blank cells with formula and in a month?
    By Imran Magsi in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-17-2017, 03:58 AM
  3. [SOLVED] Ignore blank cells with formulas or ignore NA() in a formula
    By guiismiti in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 03-24-2016, 02:13 PM
  4. [SOLVED] Return non-blank cells from range AND ignore cells with only formula w/o results
    By grafitti in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-06-2014, 08:15 AM
  5. Ignore blank cells and truly blank cells in named range?
    By hschillig in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-13-2014, 02:56 PM
  6. Replies: 5
    Last Post: 05-18-2013, 07:49 PM
  7. How can I make a macro ignore blank cells? - Blank Cells have formulas
    By mz1161 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-30-2013, 08:54 AM

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