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

copying data

ResolvedVersion 2007

Lee has attended:
Excel VBA Intro Intermediate course

Copying data

What is the code for copying data from a cell down to the point where the data in the cell to the left stops.

I have data in cells C12 to C50 I need to write a code to copy the formula i have in cell D12 to D50
The number of rows that has the data will change every time i run the macro so i need to copy the data down as far as required.(i.e not down to row 50 every time)

Thanks
Lee

RE: Copying data

Hi Lee

Thanks for the question

I would create an uinteger variable and set it equal to the rows count of the current region of the first cell in the column.

 introws = range("A1").currentregion.rows.count


you could then use a For loop to start at row one and go to the final row as determined above. At each point in the loop you could write in the formula

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:

Apply currency format quickly in Excel

To quickly apply the currency format to cell in your spreadsheet, select (highlight) the cells you wish to apply currency format to, then use Ctrl + Shift + $

This will apply a pounds symbol even though the $ key is pressed.

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.09 secs.