+ Reply to Thread
Results 1 to 5 of 5

Creating Dynamic Range Using OFFSET and COUNTA Adds Extra Rows

  1. #1
    Registered User
    Join Date
    12-01-2012
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    23

    Creating Dynamic Range Using OFFSET and COUNTA Adds Extra Rows

    Hello,

    I have a table with Column headings in Row 7 and data beginning in Row 8. All table rows are fully populated (no blank cells).

    Using the Name Manager tool, I clicked "New" and inserted the following formulas in the formula bar to create Dynamic Ranges in Columns A-C:

    =OFFSET(Database!$A$7, 1, 0, COUNTA(Database!$A:$A),1)
    =OFFSET(Database!$B$7, 1, 0, COUNTA(Database!$B:$B),1)
    =OFFSET(Database!$C$7, 1, 0, COUNTA(Database!$C:$C),1)

    After creating the above named ranges, I clicked in the formula bar to verify that the name has properly included all data in the column. What I noticed is that in column A, the formula included 3 blank lines in the range, while in the other two ranges, only 1 blank line was included.

    I thought that perhaps there was data appearing in the rows immediately below the table, but that wasn't the case. To be sure, I deleted a few rows, but that did not change the result.

    Can anyone provide the reason for this behavior?

    Thanks in advance for any replies.

    Jeff

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Creating Dynamic Range Using OFFSET and COUNTA Adds Extra Rows

    This part
    COUNTA(Database!$A:$A),
    counts all the cells in Col A, not just the ones below A7, you'll need to amend to something like
    COUNTA(Database!$A:$A)-3 or
    COUNTA(Database!$A:$A) - COUNTA(DataBase!$A$1:$A$7)
    Hope that helps.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Creating Dynamic Range Using OFFSET and COUNTA Adds Extra Rows

    Hi.

    Difficult to say for sure without seeing an actual workbook, though perhaps some of those cells contain e.g. the "" as the result of formulas in those cells?

    COUNTA registers such null strings as a positive count.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Creating Dynamic Range Using OFFSET and COUNTA Adds Extra Rows

    However, if you are working with a table, and it sounds like you are, you can just refer to the header to get the range. Let's say it's Table1 and the header of column A is "employees"

    =Table1[employees] will include the entire range within the table for column A

  5. #5
    Registered User
    Join Date
    12-01-2012
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Creating Dynamic Range Using OFFSET and COUNTA Adds Extra Rows

    Thank you, ChemistB ... I removed the heading at the top of the page and that made all of the ranges equal. Not only that, I amended the formulas to follow the following format:

    ... COUNTA(Database!$A:$A)-1

    and that removed the 1 extra row that was being added to each range.

    Much appreciated!

+ 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] Offset with Counta for picture of dynamic table is adding extra row to pic
    By Steve N. in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-07-2014, 05:29 PM
  2. Offset+counta to autoselect data range for charting purposes
    By siroco79 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-17-2013, 04:50 AM
  3. Why dynamic range doesnt work with COUNTA
    By Kushal_1991 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-31-2013, 11:17 AM
  4. Creating extra rows
    By Liberty Paintball in forum Excel General
    Replies: 1
    Last Post: 11-03-2011, 02:12 PM
  5. CountA - Dynamic Range - Macro
    By elcentro3m in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-10-2007, 02:54 PM

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