Copy using active cell with VBA

kelsonbaird

New Member
Joined
Oct 14, 2019
Messages
9
I would like to click on a cell then run a macro that would copy the cell to the left and 65 more cells below it to the active cell and the 65 below it. Anyone think of a good trick to do this? Basicly I want to click in cell N20 and have a macro that would copy M20:M85 into N20:N85, but I want to use that same macro to do the same thing with lets say Z20 (and Y20:Y85)... Any tricks would be great to hear
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Welcome to the Board!

This should do it. I even added a few "checks" in it for you.
Code:
Sub MyCopyMacro()

'   Check to make sure only one cell is selected
    If Selection.Count > 1 Then
        MsgBox "Please only select one cell"
        Exit Sub
    End If

'   Make sure you are not in column A
    If ActiveCell.Column = 1 Then
        MsgBox "You cannot copy the column to the left if you are in column A"
        Exit Sub
    End If
    
'   Copy range
    Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(65, -1)).Copy ActiveCell
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,954
Members
448,535
Latest member
alrossman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top