+ Reply to Thread
Results 1 to 4 of 4

Using INDIRECT to create a dynamic Range

  1. #1
    Registered User
    Join Date
    10-27-2022
    Location
    South Shields, England
    MS-Off Ver
    Mac 16.66
    Posts
    2

    Using INDIRECT to create a dynamic Range

    I'm attempting to create a dynamic range as part of a COUNTIF Statement and want to read the numerical part of the range from another cell.

    The cell containing the number is A1 and the value is 10. I want to count all of the NON EMPTY Cells in the range B1:B10

    I've tried the following and multiple other combinations but can't seem to get the syntax coorect

    =COUNTA(B1:INDIRECT("B"&A1)

    The outcome I'm trying to achieve is
    =COUNTA(B1:B10). - where the highlighted part is dynamically read from another cell.

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,101

    Re: Using INDIRECT to create a dynamic Range

    works for me
    =COUNTA(B1:INDIRECT("B"&A1))

    missing a bracket - but excel should have asked to autocorrect that for you
    Attached Files Attached Files
    Last edited by etaf; 10-27-2022 at 03:27 PM.
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    10-27-2022
    Location
    South Shields, England
    MS-Off Ver
    Mac 16.66
    Posts
    2

    Re: Using INDIRECT to create a dynamic Range

    Thanks for the prompt reply, i had effectively over simplified my question without checking, apologies.

    I'm effectively trying to Count unique values in a range with COUNTIF

    Works
    =SUMPRODUCT(1/COUNTIF('Sheet1 '!B1:B10,'Sheet1 '!B1:B10)). - the parts in bold i'd like to dynamically generate from cell A1.
    Doesn't Work
    =SUMPRODUCT(1/COUNTIF('Sheet1 '!B1:INDIRECT("B"&A1),'Sheet1 '!B1:INDIRECT("B"&A1)))

    If I do this without the reference to another sheet i.e. the data and the total on the same sheet it works.

    Works
    =SUMPRODUCT(1/COUNTIF(B1: INDIRECT("B"&A1), COUNTIF(B1:INDIRECT("B"&A1))))

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,974

    Re: Using INDIRECT to create a dynamic Range

    I'd use INDEX instead:

    =SUMPRODUCT(1/COUNTIF('Sheet1 '!B1:INDEX('Sheet1 '!B:B,A1),'Sheet1 '!B1:INDEX('Sheet1 '!B:B,A1)))

    You could shorten with LET
    Everyone who confuses correlation and causation ends up dead.

+ 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. Indirect to Closed Workbook to Create Dynamic Range
    By kujoking7 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-09-2018, 05:42 PM
  2. How to create a dynamic sum calculation over multiple sheets using INDIRECT?
    By The_Snook in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-04-2015, 11:06 AM
  3. Replies: 1
    Last Post: 03-03-2015, 08:41 PM
  4. [SOLVED] create chart using dynamic range (Indirect Function)
    By umbata in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-08-2015, 10:37 PM
  5. Replies: 15
    Last Post: 09-10-2013, 05:31 AM
  6. Using indirect (?) within table to create dynamic formulas
    By cotoews in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-29-2013, 07:01 PM
  7. Indirect and Dynamic Range
    By Graham Haughs in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 08-03-2006, 03:40 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