+ Reply to Thread
Results 1 to 4 of 4

VBA to resize a table based on a cell value

  1. #1
    Registered User
    Join Date
    04-19-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    4

    VBA to resize a table based on a cell value

    Win7 64 bit, and Excel 2013 user here.

    Hi, I'm fairly decent with regular excel programming, but I know next to nothing about VBA other than how to get to where you view the code.

    I have a table named Table504

    Elsewhere on my sheet in cell E7 is a value that changes. i.e. it might be 5 or 4 or any whole number.

    I inserted a button onto my sheet.

    I would like the onclick event of the button to resize Table504 to where the rows are the same as the value of cell E7. So if E7 has a value of 4, I would like Table504 to have the header row, plus 4 rows in its field where I have equations, and then I still want my Totals row at the bottom for subtotaling everything in the table. I don't want to delete any of the contents of the cells in my table, I just want to resize it, so that it would be almost an equivalent to using the filter and selecting to not show blank rows. (They aren't really blank, they just have formulas which result in a "" answer.)

    Please help, and thank you.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA to resize a table based on a cell value

    Hi,

    Try this subroutine:
    Please Login or Register  to view this content.
    Just alter the strings at the top of the code to match the location of your data/table.

    Hope this helps

  3. #3
    Registered User
    Join Date
    04-19-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA to resize a table based on a cell value

    Thank you!

    I had to save it and close the workbook and reopen the workbook before it started working, but the code works like a dream, exactly what I wanted!

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA to resize a table based on a cell value

    No problem!

    Please don't forget to click on the * next to my post to say thanks

+ 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. Resize a shape based on cell value.
    By Environment in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-19-2013, 12:35 PM
  2. Resize range (table) in VBA based on last row value in another worksheet
    By Erin1986 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-22-2013, 01:36 AM
  3. Add row to end of table and resize table automatically
    By cdthimann in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2013, 03:30 AM
  4. [SOLVED] Is it possible to resize a table and keep format & formulas?
    By NathanC in forum Excel General
    Replies: 1
    Last Post: 11-03-2012, 12:04 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