Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Code in Excel 2000 template doesn't work in Excel 2010

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?

--
Ian
--



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Code in Excel 2000 template doesn't work in Excel 2010

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

--
Ian
--
"IanC" wrote in message
...
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?

--
Ian
--






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2010 date in Excel 2000 BudW Excel Discussion (Misc queries) 2 January 5th 10 04:59 PM
2010 in Excel 2000 BudW Excel Discussion (Misc queries) 2 January 5th 10 03:47 PM
VBA Code works in Excel 2003 but won't work in Excel 2000 aglazer Excel Programming 2 September 5th 05 03:52 PM
VBA Code works in Excel 2003 but won't work in Excel 2000 [email protected] Excel Programming 0 September 5th 05 09:05 AM
Why won't this Excel 2000 code work for Excel '97? Andrea[_2_] Excel Programming 0 August 25th 03 12:24 AM


All times are GMT +1. The time now is 10:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"