+ Reply to Thread
Results 1 to 18 of 18

Row Count in Table = Cell Value

Hybrid View

  1. #1
    Registered User
    Join Date
    07-20-2009
    Location
    philly
    MS-Off Ver
    Excel 2003
    Posts
    32

    Row Count in Table = Cell Value

    I'd like to make a table in excel, 5 columns wide. I'd like the amount of rows to be based on a value in a seperate cell.

    If possible, I would like to have if dynamic, so if the number in the cell changes, so do the amount of rows.

    thanks a bunch

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Row Count in Table = Cell Value

    Create a Dynamic Named Range, which uses the OFFSET function.

    One of the arguments in the OFFSET function calls for how many rows should be included. Set this argument to reference the cell containing the number of rows to return.

    Search on Dynamic Named Ranges and post back if you need more help.

    If possible, I would like to have if dynamic, so if the number in the cell changes, so do the amount of rows.
    This is what Dynamic Named Ranges are for - to expand and contract automatically as the dataset changes in size to accomodate new entreis and deletions. No need to manually input a number to control the number of rows unless you have some other purpose for doing so.
    Last edited by Palmetto; 07-20-2009 at 02:20 PM.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Row Count in Table = Cell Value

    from the Insert Menu -> Name -> Define

    Type a name for the range in the textbox

    In the refers to paste

    =OFFSET(Sheet1!$A$1,0,0,Sheet1!$H$1,5)

    This will create a range 5 Columns wide, starting in A1 and will expand rows by the value entered in H1
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    07-20-2009
    Location
    philly
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Row Count in Table = Cell Value

    could you show me a simple example? i dont know anything about coding, but if i see an example ill be able to decipher it.

    say a table is like... B2:F4, which would be a 3 row five column table. Column b would have values 1, 2, and 3 for B2, B3, B4. Say A1 is a value (this case it would be 3). If I change it to 5, the table is then B2:F6, and column B reads 1, 2, 3, 4, 5..

    If i change A1 back to 3, the table reverts back and deletes the last 2 rows.

    can you show me a simple example and give me some code to just plug in and change depending on the table location, etc.

  5. #5
    Registered User
    Join Date
    07-20-2009
    Location
    philly
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Row Count in Table = Cell Value

    Roy,

    I followed your steps, and I change the number in H1 and I don't see anything happen. Maybe I am not following.

  6. #6
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Row Count in Table = Cell Value

    See the attached for an example.

    The named of the range is: MyTable

    When you enter a value into cell H1, you will not see any visual change, but Excel is working behind the scene to adjust the size of the named range based on your input.

    Open the attached and followed these steps to see the effect.

    In cell H1, enter any value from 1 to 3
    Press F5 key and the type "My Table" (w/o quotes) into the Reference, then press OK.
    Excel will highlight the range.
    Repeat the above using another value (1, 2 or 3) and you will see the change.
    Attached Files Attached Files
    Last edited by Palmetto; 07-20-2009 at 03:14 PM. Reason: correct spelling & clarity

  7. #7
    Registered User
    Join Date
    07-20-2009
    Location
    philly
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Row Count in Table = Cell Value

    Palmetto

    Thanks for all the help, but i dont think i was clear in my question.

    i attached a worksheet of what i would like. it think it displays what i would like pretty clearly.

    let me know what you think
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-20-2009
    Location
    philly
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Row Count in Table = Cell Value

    ^bump.

    can anybody else help with this?

    thanks for all the help!

  9. #9
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Row Count in Table = Cell Value

    See attached.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    07-20-2009
    Location
    philly
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Row Count in Table = Cell Value

    Palmetto,

    this is almost what id like.

    At the buttom of the table, I forgot to mention that I would like to sum the data in the above rows, so I need to be able to insert and delete rows between the header and the footer of the table.

    with the excel sheet you provided, you cant do that.

    this was my fault for not mentioning it before.


    Thanks!!

  11. #11
    Registered User
    Join Date
    07-20-2009
    Location
    philly
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Row Count in Table = Cell Value

    anybody have a macro for this??

    I've seen what ineed on here but i dont know how to customize it.

    table that is say 3 rows by 5 colums.

    top row has header information (size, weight, etc)

    middle row has data i need to input

    last row has footer information (summed quantities)

    i need to be able to make the middle rows greater or lesser depending on a cell value. i'd like for it to be dynamic as well

    Please any help would be greatly appreciated.

  12. #12
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Row Count in Table = Cell Value

    If you are willing to place your totals at the top of the table then it simplifies things greatly and avoids the unnecessary use of VBA code.

    You only need to drag the cells down as far as needed to copy formulas and formats when new rows are required.

    Optionally, format as many rows as you think you may ever need and let the table expand/contract based on the input cell. With the totals at the top of the table you don't need to scroll or accomodate any row insertions/deletions.

  13. #13
    Registered User
    Join Date
    07-20-2009
    Location
    philly
    MS-Off Ver
    Excel 2003
    Posts
    32

    Cell Value Driven Table Size

    Can anybody give me some help with trying to accomplish what I have attached.

    I have a list in excel that has X amount of rows. I would like to have the amount of rows be driven by the value in a cell.

    Thank you very much!!
    Attached Files Attached Files

  14. #14
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Cell Value Driven Table Size

    Why are you duplicating threads?

    I answered this in your previous thread: http://www.excelforum.com/excel-prog...ell-value.html

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Row Count in Table = Cell Value

    Threads merged. dch, please don't do that.
    Entia non sunt multiplicanda sine necessitate

  16. #16
    Registered User
    Join Date
    07-20-2009
    Location
    philly
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Row Count in Table = Cell Value

    Thanks for the feedback.

    I think this method will work ok, but I was hoping not to have to edit things so much if my number changes. Say i change from 152 to 145, i need to go back and delete things, whereas a macro will delete it for me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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