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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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