Copying data in columns

kathleen0927

New Member
Joined
Feb 7, 2018
Messages
32
Hello.

I am looking for VBA code to copy data from a column in Excel to another column (to the right) on the same worksheet. Trick is if the destination column has data in it, I need to go to the next column to the right that does NOT have data.

In my example, I have data in range C4:C25. I want to copy that to range M4:M25. Next time I use the command button/code, I want to copy C4:C25 to N4:N25, and so on.

Any advice?

Thank you!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG07Feb39
[COLOR="Navy"]Dim[/COLOR] rng [COLOR="Navy"]As[/COLOR] Range, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
 [COLOR="Navy"]Set[/COLOR] rng = Range("C4:C25")
c = 1
[COLOR="Navy"]Do[/COLOR] Until Application.CountA(rng.Offset(, c)) = 0
    c = c + 1
[COLOR="Navy"]Loop[/COLOR]
rng.Copy rng.Offset(, c)
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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