Copying to last colum

Shonky

New Member
Joined
Feb 19, 2002
Messages
41
Is there an easy way to write a macro to copy to the last column in a series of data? EG I have info in Column C (which I know is there), but I want to copy that to Column Alpha, where Column Alpha is unknown, but is the first column with no data in it?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
On 2002-03-04 04:58, Shonky wrote:
Is there an easy way to write a macro to copy to the last column in a series of data? EG I have info in Column C (which I know is there), but I want to copy that to Column Alpha, where Column Alpha is unknown, but is the first column with no data in it?

If you want to copy data to the last column in that particular row, you could use:

Range("C1").Copy Destination:=Range("C1") _
.End(xlToRight).Offset(0, 1).Address

which will copy the data in C1 to the first unused column in row 1. If you want to copy to a specific column all the time (say you have headers in row 1 but you might not have data in all the columns), you could use:

Dim LastColumn As Integer
LastColumn = Range("A1").End(xlToRight).Offset(0, 1).Column
Range("C10").Copy Destination:=Cells(10, LastColumn)


Hope this helps you out.

Regards,
 
Upvote 0

Forum statistics

Threads
1,223,374
Messages
6,171,727
Members
452,419
Latest member
mapa

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