Consulting

Results 1 to 12 of 12

Thread: How to add rows to tables using macros

  1. #1

    Red face How to add rows to tables using macros

    I have created a series of tables (each say 9 columns by 6 rows) below each other in a worksheet. It is the intention to input data into each table, starting at the top row and working down to the bottom. Some of the cells will include functions which are calculated once data is inserted into adjacent cells in that row. At the very bottom of each table there will be a TOTALS row which adds figures from the rows above.
    However, once all the rows are completely filled with data I would like the option of adding a new row at the bottom of the table, but above the TOTALS row. This to be done using a Macro button rather than manually adding a row at the bottom and then copying all the functions to corresponding cells below.

    So, the question is - How can I insert subsequent rows, using a Macro button, such that they always appear at the bottom of the list, i.e. directly above the TOTALS row. Following on from that, the TOTALS row would have had to recognise the additional row(s) to ensure a correct total is displayed.

    But then, moving on from the first table, I may want to add a row to a subsequent table using another macro. How can I do that?

    Alternatively, I could provide hidden rows for each table but how could I unhide one row at a time (when each button is pressed)?

    Any help appreciated
    Last edited by Bob Phillips; 08-19-2010 at 06:46 AM. Reason: Removed HTML noise

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Please provide a sample file showing a "before" and "after" version of what you want.

    We are what we repeatedly do. Excellence, therefore, is not an act but a habit.
    Aristotle

  3. #3

    Add a row to a table using a macro

    Do you have an E-mail I could send to?

    Graham

  4. #4
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    Please post your example workbook on the forum so everyone can look into the problem and provide a solution.

  5. #5
    How do I get my workbook onto the system?

  6. #6
    VBAX Regular
    Joined
    Jun 2007
    Posts
    69
    Location
    Start a reply (such as what I'm doing right now). Scroll the page down and you'll see a box entitled "Additional Options" and the 2nd frame (light green <in my case> sub-box is headed "Attach Files". Click the Manage Attachments button; on the new dialog that opens, click Browse to search your computer for the file you want to upload.

    Since you can only attach a single file, if for any reason you need to upload 2 or more files, please zip them up before uploading. This new dialog shows you the file types/extension names that you can upload; again, if you file has a different extension, please zip it so it will upload without complaining.

    I hope this helps, ask more questions if you need a little more help, I'm sure someone here will give you a hand.

    Cheers,
    Ron McKenzie
    Windermere, FL
    (living in the huge shadow of a tiny rodent)

  7. #7

    Adding rows to a table using a macro

    I've uploaded my spreadsheet so that you can have a look at what I am trying to do. You will note that I have a series of tables in which financial information will be put. To keep the initial tables in full view and printable on a sheet of A4 paper I have kept the number of rows in each table to a minimum. However one or all of the tables may need to be increased in size by adding additional rows. I would like to do this by the press of a button. The new row would need to include formulae where appropriate. Presumably each button would need a slightly different formula. I did manage to get a macro of sorts to work but found that if I pressed a button for a higher level table and added a row it caused a problem for buttons further down and the row wasn't added in the remaining tables in exactly the right place, i.e. above the TOTALS row.

    NOTE : If adding a row is too difficult then an alternative could involve providing each table with a number of hidden rows, which include the necessary formulae. Maybe then the press of a button could reveal the next hidden row above the TOTALS row. Each button would need to be specific to each table, i.e. Button 1 for Rows 10 to 100 say, where Rows 20 to 100 may be hidden to start with, Button 2 for Rows 101 to 200 with Rows 1015 to 200 to start with etc. etc.

    Thanks for your help.

    Graham

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,057
    Location
    Just a minor correction to Ron's advice
    Quote Originally Posted by RonMcK3
    Start a reply (such as what I'm doing right now). Scroll the page down and you'll see a box entitled "Additional Options" and the 2nd frame (light green <in my case> sub-box is headed "Attach Files". Click the Manage Attachments button; on the new dialog that opens, click Browse to search your computer for the file you want to upload.
    Actually if you click on "Go Advanced" after creating your reply, then scroll down to "manage attachments".....
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Apparently, this has been cross-posted at http://www.mrexcel.com/forum/showthread.php?t=490112
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,057
    Location
    All that effort to supply an answer and then you fail to advise the members here that another forum is currently working on a solution for you.....
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  11. #11
    Unfortunately, no-one supplied any comments or answers at all so I had to try elsewhere. In fact I am pretty sure I inserted a link to the other forum but it doesn't seem to have registered.

  12. #12
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,057
    Location
    Quote Originally Posted by mesteptoe
    Unfortunately, no-one supplied any comments or answers at all so I had to try elsewhere.
    This statement of yours is blatantly incorrect. On the 20th of August, Geekgirlau & on the 23rd of the same month Lynnow posted responces suggesting you post a workbook to the forum so we could see your issue. It sometimes happens that when an issue arises, the explanation or (description) offerred doesn't always make the issue very clear to others, hence the requests to attatch a workbook.

    On the 23rd you started posting on another forum, as you have every right to do so. Out of respect to both Mr Excel and VBAEpress you did not indicate to either forum that you were crossposting.

    On the 24th you were made aware of the issue of cross posting on the Mr Excel forum and the reasons why when cross posting you really should post a link. I can assure you that the same reasons are just a valid on any forum you may wish to use.

    In fact I am pretty sure I inserted a link to the other forum but it doesn't seem to have registered.[/quote]

    If this is true then I did not notice any comment from you in regard to this point. You could have asked how, as you did in relation to attaching a workbook, and assistance would have been rendered to you.

    In future please post all links to other forums that are dealing with the same issue.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •