Copy with alternance 2 cells (ping-pong)

Maurizio

Well-known Member
Joined
Oct 15, 2002
Messages
687
Office Version
  1. 2007
Platform
  1. Windows
Hi all,
I 'd like a macro able to select-copy as ping pong into a same sheet:

1] If I run macro is selected-copied cell A2:

Range("A2").Select
Range("A2").Copy

2] If I run same macro again [while is active Range("A2").Copy)] is selected-copied, now, cell A5:

Range("A5").Select
Range("A5").Copy

3] and if I re-run macro again I 'd like to go back like 1]

Tia, Maurizio.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Code:
Sub Macro4()
If ActiveCell.Address = Range("a2").Address Then
    [a5].Copy
    ElseIf ActiveCell.Address = Range("a5").Address Then
    [a2].Copy
        Else
        MsgBox ("Neither cell A2 or A5 is the active cell")
End If
End Sub
 
Upvote 0
Hi north19701,
many thanks for your idea!

This runs OK as I want.

Sub flipflop()
If ActiveCell.Address = Range("a2").Address Then
[a5].Select
[a5].Copy
ElseIf ActiveCell.Address = Range("a5").Address Then
[a2].Select
[a2].Copy
' Else
' MsgBox ("Neither cell A2 or A5 is the active cell")
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,972
Messages
6,122,530
Members
449,088
Latest member
RandomExceller01

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