ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel macro to copy the rightmost column to a new column (https://www.excelbanter.com/excel-discussion-misc-queries/446230-excel-macro-copy-rightmost-column-new-column.html)

Vasanth

Excel macro to copy the rightmost column to a new column
 
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 data 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 vary day to day.

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

Please help me in this issue

Claus Busch

Excel macro to copy the rightmost column to a new column
 
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
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

Vasanth

Thanks claus .. It worked.





Quote:

Originally Posted by Claus Busch (Post 1602370)
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
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2



All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com