![]() |
copy current cells to the right
Hello everybody,
Hope someone will help... I have a worksheet with 4 columns of data. I want to write a macro to copy the data on the first 3 columns, current row, and then paste them 1 cell to the right. For example, if the current cell is on row 3: copy A3, B3, C3 paste to B3, C3, D3 if the current cell is row 10: copy A10, B10, C10 paste to B10, C10, D10 Second question: How should I change the macro if I don't have a fix column reference? For example, if the current cell is on B3: copy B3, C3, D3 paste to C3, D3, E3 if the current cell is on D4: copy D4, E4, F4 paste to E4, F4, G4 I am using Excel 2000 & 2002. Many thanks, Marisa |
copy current cells to the right
Hi,
One way Sub RightMove Dim Rw, Col Rw=Activecell.Row: Col=Activecell.Column Range(Cells(Rw, Col), Cells(Rw, Col+2)).Copy Cells(Rw, Col+1) End Sub Should you wish to delete the now duplicated first cell insert Cells(Rw, Col) = "" before End Sub regards, Don -- "Marisa" wrote in message ... Hello everybody, Hope someone will help... I have a worksheet with 4 columns of data. I want to write a macro to copy the data on the first 3 columns, current row, and then paste them 1 cell to the right. For example, if the current cell is on row 3: copy A3, B3, C3 paste to B3, C3, D3 if the current cell is row 10: copy A10, B10, C10 paste to B10, C10, D10 Second question: How should I change the macro if I don't have a fix column reference? For example, if the current cell is on B3: copy B3, C3, D3 paste to C3, D3, E3 if the current cell is on D4: copy D4, E4, F4 paste to E4, F4, G4 I am using Excel 2000 & 2002. Many thanks, Marisa |
copy current cells to the right
Thanks a lot, Don. That's very helpful.
Marisa -----Original Message----- Hi, One way Sub RightMove Dim Rw, Col Rw=Activecell.Row: Col=Activecell.Column Range(Cells(Rw, Col), Cells(Rw, Col+2)).Copy Cells(Rw, Col+1) End Sub Should you wish to delete the now duplicated first cell insert Cells(Rw, Col) = "" before End Sub regards, Don -- "Marisa" wrote in message ... Hello everybody, Hope someone will help... I have a worksheet with 4 columns of data. I want to write a macro to copy the data on the first 3 columns, current row, and then paste them 1 cell to the right. For example, if the current cell is on row 3: copy A3, B3, C3 paste to B3, C3, D3 if the current cell is row 10: copy A10, B10, C10 paste to B10, C10, D10 Second question: How should I change the macro if I don't have a fix column reference? For example, if the current cell is on B3: copy B3, C3, D3 paste to C3, D3, E3 if the current cell is on D4: copy D4, E4, F4 paste to E4, F4, G4 I am using Excel 2000 & 2002. Many thanks, Marisa . |
All times are GMT +1. The time now is 04:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com