Code in Excel 2000 template doesn't work in Excel 2010

I

IanC

I have the following code working as expected in Excel 2000. It is
designed to populate a cell in column Q with a tick OR a cell in
column S with a cross.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----- ENABLE TICKS IN RELEVANT BOXES -----
Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("Q18:Q19")) Is Nothing Then
With Target
If .Value = Chr(252) Then
.Value = ""
Else
.Value = Chr(252)
.Font.Name = "Wingdings"
Range("S" & ActiveCell.Row & "").Value = ""
End If
End With
End If
If Not Intersect(Target, Range("S18:S19")) Is Nothing Then
With Target
If .Value = Chr(251) Then
.Value = ""
Else
.Value = Chr(251)
.Font.Name = "Wingdings"
Range("Q" & ActiveCell.Row & "").Value = ""
End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub



In Excel 2010 the exclusivity doesn't work (ie it will generate an
tick AND a cross on the same line). If I remove the "On Error" line In
Excel 2010, an error is generated on the line:

..Font.Name = "Wingdings"

The error is "Run-time error '1004': Unable to set the Name property
of the Font class". Excel 2010 VBA editor offers Name as an option to
follow Font suggesting the combination Font.Name is acceptable.

Any ideas why this is happening?
 
I

IanC

I've sorted it. It appears to be yet another inconsistency between
Excel versions where certain actions in Excel 2010 will not work on a
protected worksheet even though they work perfectly on a protected
sheet in Excel 2000.

In my code below I have wrapped the font change line in
unprotect/protect commands as below:

Worksheets("Service Report").Unprotect
.Font.Name = "Wingdings"
Worksheets("Service Report").Protect
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top