![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Location: Australia
Posts: 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?
|
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
|
Quote:
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,
__________________
Barrie Davidson "You're only given a little spark of madness. You mustn't lose it." - Robin Williams |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|