VBA to show value of another cell using a checkbox

bademployee

Board Regular
Joined
Aug 19, 2010
Messages
184
Hi all,

I'm chasing VBA to perform the following:

I have a check box in Sheet1 A1, when checked I need the value of Sheet2 D4 shown in Sheet1 A2.

Thanks in advance

Mark
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try
Code:
Sub CheckBoxChecked()

With Sheet1
    If .CheckBoxes(1).Value = 1 Then
    'Check box is checked:
        .Cells(2, 1).Value = Sheet2.Range("D4").Value
    Else
    'CheckBox is not checked:
        .Cells(2, 1).ClearContents
    End If
End With


End Sub
 
Upvote 0
Try
Code:
Sub CheckBoxChecked()

With Sheet1
    If .CheckBoxes(1).Value = 1 Then
    'Check box is checked:
        .Cells(2, 1).Value = Sheet2.Range("D4").Value
    Else
    'CheckBox is not checked:
        .Cells(2, 1).ClearContents
    End If
End With


End Sub

I must be doing something wrong...

Sheet 1 is actually labelled "Blends"

Sheet2 is labelled "Price Input"

The check box is ActiveX (don't know if that makes a difference).

Checkbox is located in "Blends" T21

I need the value in "Price Input" AD2 to show in "Blends" S21.

Thanks for your help.

Mark
 
Upvote 0
Try
Code:
Private Sub CheckBox1_Click()
   If CheckBox1 = True Then
      Range("S21").Value = Sheets("Price Input").Range("AD2").Value
   Else
      Range("S21").ClearContents
   End If
End Sub
This needs to go in the "Blends" sheet code module, changing the checkbox name if needed
 
Upvote 0
Try
Code:
Private Sub CheckBox1_Click()
   If CheckBox1 = True Then
      Range("S21").Value = Sheets("Price Input").Range("AD2").Value
   Else
      Range("S21").ClearContents
   End If
End Sub
This needs to go in the "Blends" sheet code module, changing the checkbox name if needed

Perfect!

Thanks for your help
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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