PDA

View Full Version : How to add rows to tables using macros



mesteptoe
08-19-2010, 06:24 AM
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

geekgirlau
08-19-2010, 10:23 PM
Please provide a sample file showing a "before" and "after" version of what you want.

mesteptoe
08-23-2010, 01:03 AM
Do you have an E-mail I could send to?

Graham

lynnnow
08-23-2010, 05:58 AM
Please post your example workbook on the forum so everyone can look into the problem and provide a solution.

mesteptoe
08-23-2010, 06:13 AM
How do I get my workbook onto the system?

RonMcK3
08-23-2010, 11:27 AM
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,

mesteptoe
08-24-2010, 01:05 AM
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:dunno

Aussiebear
08-24-2010, 01:59 AM
Just a minor correction to Ron's advice
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".....

Bob Phillips
08-25-2010, 01:21 PM
Apparently, this has been cross-posted at http://www.mrexcel.com/forum/showthread.php?t=490112

Aussiebear
08-26-2010, 02:09 AM
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.....

mesteptoe
08-26-2010, 02:21 AM
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.

Aussiebear
08-27-2010, 03:00 AM
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.