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

code copying line above

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

Code for copying line above

ResolvedVersion 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:

Select Single Data Marker

To select a single data marker in a chart, ie line, bar or column;
After you have pressed Ctrl+Click (to select the entire chart) you can press the Up or Down arrows to select a data series, then press the Left or Right arrow to select a data point within that series.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.