Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

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

Copying the last column and pasting next to it

ResolvedVersion 365

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:

Line breaks in a cell

You can control the line breaks for multiple-line headings or labels in your Microsoft Excel worksheet, just like you do in Microsoft Word. Here's how to do it.

Click the cell where you want the label or heading to appear.
Type the first line of information.
Press ALT+ENTER.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.11 secs.