Excel macro to copy the rightmost column to a new column

V

Vasanth

Hi all,


I need a excel macro to copy the 3 rightmost columns to next 3 columns.


Eg.


if i have data from column A to Column G then I need to copy the dat
from Column E to Column G to copied to
Column H to Column J.

I cant hardcode the column names in macro as the column range may var
day to day.

Is there any way this can be done in an excel macro.

Please help me in this issu
 
C

Claus Busch

Hi Vasanth,

Am Mon, 4 Jun 2012 13:10:07 +0000 schrieb Vasanth:
if i have data from column A to Column G then I need to copy the data
from Column E to Column G to copied to
Column H to Column J.

try:

LCol = Cells(1, Columns.Count).End(xlToLeft).Column
LRow = Cells(Rows.Count, 1).End(xlUp).Row

Range(Cells(1, LCol - 2), Cells(LRow, LCol)).Copy _
Destination:=Cells(1, LCol + 1)


Regards
Claus Busch
 
V

Vasanth

Thanks claus .. It worked.




Hi Vasanth,

Am Mon, 4 Jun 2012 13:10:07 +0000 schrieb Vasanth:
-

try:

LCol = Cells(1, Columns.Count).End(xlToLeft).Column
LRow = Cells(Rows.Count, 1).End(xlUp).Row

Range(Cells(1, LCol - 2), Cells(LRow, LCol)).Copy _
Destination:=Cells(1, LCol + 1)


Regards
Claus Busch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top