Macro - how do I write a loop and a copy command?

PooS

New Member
Joined
Feb 13, 2005
Messages
3
Hi,

I would really appreciate if someone could help me writing a macro.

Code:
STEP 1
Read a value from Sheet1!A1. This particular value is the number of how many active rows in Sheet1 that contains data.

Cell A1 contains the formula =count(A10:A65536)

STEP 2
START LOOP

Step 2.1
After reading the value in Sheet1!A1, a formula reference in Sheet2!A1 should change correspondingly, and “point” to the last active row in Sheet1.

If Sheet1 only contains 5 active from A10 to A14, the cell reference should be =Sheet1!A14.

The next loop should change the reference in Sheet2!A1 to =Sheet1!A13, and so on. The final change of reference should be =Sheet1!A10.

Step 2.2
The next step in the loop should be a copy command. The macro should copy the last active row value inn Column B in Sheet1, and paste the value only (not formula) at the correspondingly row and column in Sheet2.

IOW – Copy value in Sheet1!B15 and paste the value only in Sheet2!B15. 
The next loop should copy the value in Sheet1!B14 and paste the value in
Sheet2!B14 and so on.

END LOOP

Sincerely,
PooS
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,203,078
Messages
6,053,402
Members
444,661
Latest member
liamoohay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top