vba insert rows

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA insert rows

VBA insert rows

resolvedResolved · Low Priority · Version 2003

Tim has attended:
Excel Intermediate course
Outlook Advanced course
Excel VBA Intro Intermediate course
Excel Advanced course
PowerPoint Introduction course
PowerPoint Intermediate Advanced course
Excel Advanced course
Excel Advanced - For Power Users course

VBA insert rows

Could you help me with the code requirdd insert rows on multiple worksheets

RE: VBA insert rows

Hi Steve

Thanks for your question.

Can you just clarify for me the following points.

1. Do you need to insert single or multiple rows?
2. If the later, are they grouped together, or spread over the entire sheet

Thanks

Stephen

RE: VBA insert rows

Hi Stephen,

I have created some management accounts with a worksheet for each cost centre. If then we want to create a new line in the accounts, a new type of travel cost etc., I want to be able to insert a new line in each cost centres accounts and add into the line the name of the new cost and a formula.

Hope that is clearer.

Cheers

Tim

RE: VBA insert rows

Hi Tim

Thanks for the update.

I suggest the following approach

1. Use a "For each" loop to go to each worksheet in the workbook.
2. Within the loop (for each sheet), insert a new row in the appropriate place. The following is a sample of code for this.

Range("A2").Rows.Insert shift:=xlDown


3. set the new cost and formula as the values of the relevant cell.

Hope this helps

Regards

Stephen

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

How to select certain data in an Excel 2010 workbook

If you want to select the correct data set in a page full of data, the most accurate and efficient way of doing this is to use the ''Shift and Click'' technique.

For example: If you want to select all data in cells A2 to E10, then click on cell A2, hold down the Shift key and click on cell E10 and all the data you want to see is highlighted.

Keep holding down the Shift key and you can move from cell E10 to any other cell in the spreadsheet.

View all Excel hints and tips


Server loaded in 0.07 secs.