copying last column and

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Copying the last column and pasting next to it | Excel forum

Copying the last column and pasting next to it | Excel forum

resolvedResolved · Medium Priority · Version 365

Jo has attended:
Excel VBA Introduction course
Excel VBA Intermediate course

Copying the last column and pasting next to it

Hi,

I have many spreasheets that need updating regularly, and that involves copying that last column of the data and pasting it in the empty column to it's right. So far I have managed to work out the copy bit, but am struggling to get it to paste in the next column, any ideas?

Here's what I have so far:

Sub LastColumn()
Dim LastCol As Long

With ThisWorkbook.Sheets("LO TVM Data")
LastCol = Cells(1, .Columns.Count).End(xlToLeft).Column
Columns(LastCol).Copy


End With

End Sub

Thanks,

Jo

RE: Copying the last column and pasting next to it

Hello Jo,

Thank you for your question. Here is a solution that works for me:

Sub LastColumn()
Dim LastCol As Long

With ThisWorkbook.Sheets("LO TVM Data")
LastCol = Cells(1, .Columns.Count).End(xlToLeft).Column
Columns(LastCol).Copy Destination:=Cells(1, LastCol + 1)

End With

End Sub

I added: Destination:=Cells(1, LastCol + 1)

This line simply instructs Excel to paste the last column's data one column to the right.

I hope this works for you.

Kind regards
Marius Barnard
STL

RE: Copying the last column and pasting next to it

Hi Marius,

Thats perfect, thanks very much! I was trying to do it with OFFSET!

Regards,

Jo

 

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:

Quick Zooming in Excel with rollerball mouses

To zoom in and out of your page hold down the control key and roll the wheel up and down. This will zoom up and down 15% at a time.

View all Excel hints and tips


Server loaded in 0.07 secs.