Checkbox code: Works in 2003, not in 2007

JDDMichael

New Member
Joined
Sep 19, 2011
Messages
1
Hey all,

So I am a bit baffled why the following code works fine on one PC but does nothing if I send the XLS over to someone else with a different version of Excel:

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Excel.Range, Cancel As Boolean)
Dim TopRow As Long
Dim BottomRow As Long
Dim MyTick As String
'--------------------------------------------------
MyTick = Chr(252) ' Wingdings font tick
TopRow = 3
BottomRow = 100
'- check cell is within limits set
If Target.Column = 2 Or Target.Column = 4 Or Target.Column = 6 Or Target.Column = 8 Or Target.Column = 10 _
And Target.Row >= TopRow _
And Target.Row <= BottomRow Then
If Target.Value = "" Then ' if cell empty
Target.Value = MyTick ' put tick
Else ' otherwise
Target.Value = "" ' remove tick
End If
Target.Offset(1, 1).Select ' move 1 cell down
End If
End Sub



Any ideas?

** Update: Uhg... Newb mistake. All of the other systems are disabling macros... **
 
Last edited:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
It COULD depend on where they put the code -- it must not be in a regular module. Also, your code has an error in it, namely this line:
If Target.Column = 2 Or Target.Column = 4 Or Target.Column = 6 Or Target.Column = 8 Or Target.Column = 10 _
And Target.Row >= TopRow _
And Target.Row <= BottomRow Then

should be:
If (Target.Column = 2 Or Target.Column = 4 Or Target.Column = 6 Or Target.Column = 8 Or Target.Column = 10) _
And Target.Row >= TopRow _
And Target.Row <= BottomRow Then
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

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