copy current cells to the right

M

Marisa

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
 
D

Don Lloyd

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
 
M

marisa

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
--




.
 

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