Brilliant code doesn't work

jpmccreary

New Member
Joined
Jul 21, 2010
Messages
11
I have a form with about 15 check boxes. A few columns over I have an important message that I want displayed when the check box is checked. I know that I can write code for each checkbox to display it's message. Just trying what I thought would be a brilliant shortcut and code saver. I am trying to use the Worksheet Change event. I set the checkbox's linked cell to the cell 1 column to the right of the cell with the important message. The whole 'cell link' column is named "Target_Column". I use an InRange function to determine if a change is made in the Target_Column range. If it is, and the value of the target is true, the code is supposed to display a message that is equal to the target offset by -1 column (the important message cell).

This code works when I change the "target" manually but when I check the box, and the target changes, the event does not trigger. Is there something about the change from the check box that keeps the Worksheet Change event from firing? I have tried both Form and ActiveX checkboxes. Neither works.
Here is the event change code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim sTarget As String
Dim sRange As String
Dim bInRange As Boolean
Dim sMessage As String

sTarget = Target.Address
sRange = Range("Target_Column").Address
bInRange = InRange(Range(sTarget), Range(sRange))

If bInRange = True And Target.Value = True Then

sMessage = Target.Offset(0, -1).Value
MsgBox "Distribution Restrictions: " & sMessage, vbOKOnly

End If

End Sub
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,391
Messages
6,124,673
Members
449,178
Latest member
Emilou

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