Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can't get userinterface variant to work on mac.

I have a several cells on a worksheet form that I want the user to be able to
double click and have the cell toggle back and forth between "Yes" and "No".
I used a before double click event on the worksheet to call a macro (in
module 1) that determines if one of the target cells has been double clicked.

Tried using the protect method with the UserinterfaceOnly variant and I get
the following error message:


"Runtime error 1004
The cell or chart you are trying to change is protected.... " When i hit debug
it goes to the line in the macro that changes the value of the cell to either
"Yes" or "No".

Following are 2 ways i tried to protect the sheet:

Private Sub Worksheet_Activate()
ActiveSheet.Protect Password:= _
"pass", UserInterfaceOnly:=True
End Sub


I also tried the following version in the macro that is triggered by double
clicking on the target cell:

Public Sub ChooseYesNo(Trng As Range)

Dim YNrng As Range
Dim YNrngb As Range
Set YNrng = Range("FormCompleted")
Set YNrngb = Range("WklyHrsSigned")

ActiveSheet.Protect Password:= _
"pass", UserInterfaceOnly:=True

If Not Intersect(Trng, YNrng) Is Nothing Then
If YNrng = UCase("NO") Or YNrngb = UCase("Yes") Then

' following is the line that the macro gets stuck on

YNrng.Value = UCase("yes")

Range("FormCompletedLabel").Select
Else
YNrng.Value = UCase("no")
End If
Else
If Not Intersect(Trng, YNrngb) Is Nothing Then
If YNrngb = UCase("NO") Then
YNrngb.Value = UCase("yes")
YNrng.Value = UCase("yes")
Else
YNrngb.Value = UCase("no")
End If
End If
End If

Set YNrng = Nothing
Set YNrngb = Nothing

End Sub


Both these attempts do protect the sheet - but give me the error message
when I double click the target cells.

The yesno toggling macro works fine with protection off.

Anybody have a suggestion?
Thanks
Richard


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Can't get userinterface variant to work on mac.

Win 98 SE, xl97 SR2

Your code worked well for me with the sheet protected.

Are all three named ranges defined on that sheet?
FormCompleted
WklyHrsSigned
FormCompletedLabel

If you can't get it to work, then try unprotecting the sheet at the top of
your code and reprotect it at the bottom.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel
As Boolean)
If Target.Count 1 Then Exit Sub
ChooseYesNo Target
Cancel = True
End Sub



Public Sub ChooseYesNo(Trng As Range)

Dim YNrng As Range
Dim YNrngb As Range
Set YNrng = Range("FormCompleted")
Set YNrngb = Range("WklyHrsSigned")

ActiveSheet.Protect Password:= _
"pass", UserInterfaceOnly:=True

If Not Intersect(Trng, YNrng) Is Nothing Then
If YNrng = UCase("NO") Or YNrngb = UCase("Yes") Then

' following is the line that the macro gets stuck on

YNrng.Value = UCase("yes")

Range("FormCompletedLabel").Select
Else
YNrng.Value = UCase("no")
End If
Else
If Not Intersect(Trng, YNrngb) Is Nothing Then
If YNrngb = UCase("NO") Then
YNrngb.Value = UCase("yes")
YNrng.Value = UCase("yes")
Else
YNrngb.Value = UCase("no")
End If
End If
End If

Set YNrng = Nothing
Set YNrngb = Nothing

End Sub


"Richard Garber" wrote in message
...
I have a several cells on a worksheet form that I want the user to be able
to
double click and have the cell toggle back and forth between "Yes" and "No".
I used a before double click event on the worksheet to call a macro (in
module 1) that determines if one of the target cells has been double
clicked.

Tried using the protect method with the UserinterfaceOnly variant and I get
the following error message:


"Runtime error 1004
The cell or chart you are trying to change is protected.... " When i hit
debug
it goes to the line in the macro that changes the value of the cell to
either
"Yes" or "No".

Following are 2 ways i tried to protect the sheet:

Private Sub Worksheet_Activate()
ActiveSheet.Protect Password:= _
"pass", UserInterfaceOnly:=True
End Sub


I also tried the following version in the macro that is triggered by double
clicking on the target cell:

Public Sub ChooseYesNo(Trng As Range)

Dim YNrng As Range
Dim YNrngb As Range
Set YNrng = Range("FormCompleted")
Set YNrngb = Range("WklyHrsSigned")

ActiveSheet.Protect Password:= _
"pass", UserInterfaceOnly:=True

If Not Intersect(Trng, YNrng) Is Nothing Then
If YNrng = UCase("NO") Or YNrngb = UCase("Yes") Then

' following is the line that the macro gets stuck on

YNrng.Value = UCase("yes")

Range("FormCompletedLabel").Select
Else
YNrng.Value = UCase("no")
End If
Else
If Not Intersect(Trng, YNrngb) Is Nothing Then
If YNrngb = UCase("NO") Then
YNrngb.Value = UCase("yes")
YNrng.Value = UCase("yes")
Else
YNrngb.Value = UCase("no")
End If
End If
End If

Set YNrng = Nothing
Set YNrngb = Nothing

End Sub


Both these attempts do protect the sheet - but give me the error message
when I double click the target cells.

The yesno toggling macro works fine with protection off.

Anybody have a suggestion?
Thanks
Richard



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
To get a sum for variant currency values [email protected] Excel Discussion (Misc queries) 3 November 24th 07 01:07 PM
Variant as matrix curious Excel Programming 5 June 2nd 04 04:18 PM
Variant Array Steph[_3_] Excel Programming 1 June 2nd 04 01:29 AM
Variant to String Chip Pearson Excel Programming 1 September 3rd 03 03:10 PM
DLLs and VBA: Who free's a variant? Keith Willshaw Excel Programming 0 August 6th 03 09:42 AM


All times are GMT +1. The time now is 06:32 AM.

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"