Copy and paste entire column to the next column

clovisjim

New Member
Joined
Jul 8, 2016
Messages
14
For the life of me I can't understand why this works. Would someone explain this to me?

Code:
Columns(last_col).Copy Columns(last_col + 1)

Thanks!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try this:
Assuming row (1) has the most columns

Code:
Sub Copy_LastColumn()
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
Columns(LastColumn).Copy Columns((LastColumn + 1))
End Sub
 
Upvote 0
Thanks. The original code I posted works, but I don't understand it. Specifically, the snippet below. How does Excel know to paste?

Columns(last_col).Copy Columns(last_col + 1)
 
Upvote 0
Excel is smart enough to know if you copy then you normally want to paste.

Just like:
Range("A1").copy Destination:= Sheets("George").Range("B6")
 
Upvote 0

Forum statistics

Threads
1,216,086
Messages
6,128,736
Members
449,466
Latest member
Peter Juhnke

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