Copy and Paste Values relative to Macro Button

jyu27

New Member
Joined
Aug 10, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello, I'm trying to create 1 macro button that will copy the cell to the right of the button and paste it into the cell that to the left of the button. Trying to figure this out but having some trouble getting the macro code.

For example. I want the button in B1 to copy "test" from C1 and paste values to A1

The same button located in B2 would copy "apples" from C2 and paste values to A2

Thank you!

Screenshot 2023-08-10 095949.png
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try this, assigning it as the macro for each button
VBA Code:
Sub RunForButs()
  
    Dim where As String, rng As Range
    
    where = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address
    Set rng = Range(where)
    rng.Offset(, -1).Value = rng.Offset(, 1).Value

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,174
Messages
6,123,454
Members
449,100
Latest member
sktz

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