Checkbox macro per row

rcb007

Board Regular
Joined
Nov 12, 2020
Messages
90
Office Version
  1. 365
Platform
  1. Windows
How could I write a macro that when its checked, it would take A1 and Paste the Value into C1?

With that, If I place a checkbox at each row, it will perform the same macro action as Row 1?

If I have the following:

A B C D
1 previous override current value original [Checkbox]
2
3

If the Values in A1 and B1 have formulas, would it still paste the formula or just paste the value?

Thank you!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
You could do this with a formula by linking each checkbox to a cell then having the formula in column C as =IF(LinkedCell, A1,"")
Otherwise you could link a this macro to all of your checkboxes:

VBA Code:
Sub CopyValue()

Dim CheckBoxName As String
Dim SelectedCheckBox As CheckBox
Dim CheckBoxRow As Long
Dim ValueToInput As Variant

    CheckBoxName = Application.Caller
    Set SelectedCheckBox = ActiveSheet.CheckBoxes(CheckBoxName)
    CheckBoxRow = SelectedCheckBox.TopLeftCell.Row
    ValueToInput = VBA.IIf(SelectedCheckBox.Value = 1, Range("A" & CheckBoxRow).Value, "")
    Range("C" & CheckBoxRow).Value = ValueToInput

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,254
Members
448,879
Latest member
oksanana

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