code copying line above

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Code for copying line above

Code for copying line above

resolvedResolved · Low Priority · Version 2003

Joanne has attended:
Excel VBA Intro Intermediate course

Code for copying line above

How can I write a code that copies the line above into a blank row underneath where the line above has a load of formatting and formulae.

RE: Code for copying line above

Hi Joanne, thanks for your query. The easiest way to write this is to record it! It depends a lot on what your're trying to do and the structure of your data, but try recording yourself simply copying the row, moving down a row and pasting. That will take everything with it.

Alternatively, you could do the same and get the code to OFFSET one row down when it performs the copy, and furthermore you could loop through each cell making the value, numberformat etc of the cell below the same as the source cell. VBA is a flexible tool and there are usually more than one way of achieving the same thing. I'd start with the macro recorder and tweak the code from there.

Hope this helps,

Anthony

Thu 29 Jul 2010: Automatically marked as resolved.

 

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:

The dual nature of toolbar buttons

Many toolbar buttons are dual purpose, though the two purposes are often linked in some way. For example, Align Left aligns a cell's contents to the left of the cell. However, hold down Shift and press the Align Left button: Excel aligns the cell contents to the right.
You may respond: So what? Well, you can reduce the number of buttons on your toolbar to make your screen less cluttered and allow more room for, perhaps, some of your own commands. After all, what's the point of an Align Right button when Shift+Align Left does the same thing?

View all Excel hints and tips


Server loaded in 0.08 secs.