Link to home
Start Free TrialLog in
Avatar of babychango
babychango

asked on

VBA code to copy and paste a cell

I m looking for a VBA code that woud allow me to copy the selected cell in column A and move it a cell in clumn b that is 11 rows up and 2 columns to the right.
ASKER CERTIFIED SOLUTION
Avatar of Shanan212
Shanan212
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>  I m looking for a VBA code that woud allow me to copy the selected cell in column A and move it a cell in clumn b that is 11 rows up and 2 columns to the right.

Not to be too picky or anything, but column B will never be "2 columns to the right" of column A.  It will always be 1 column to the right.  ;-)

Shanon's code will (of course) only work if the active cell is in row 12 or higher.  You may want to add some error handling or check the address of the current cell before running the copy and paste.

Sub Sample()

    Dim Cop
    
    Cop = ActiveCell.Value
    i = ActiveCell.Row
    If i >= 12 Then
         Cells(ActiveCell.Row - 11, ActiveCell.Column + 2).Value = Cop
    End If
End Sub

Open in new window