Results 1 to 22 of 22

Hide command button if worksheet is protected

Threaded View

PRodgers4284 Hide command button if... 10-03-2009, 05:26 AM
DonkeyOte Re: Hide command button if... 10-03-2009, 05:29 AM
PRodgers4284 Re: Hide command button if... 10-03-2009, 05:34 AM
DonkeyOte Re: Hide command button if... 10-03-2009, 05:38 AM
PRodgers4284 Re: Hide command button if... 10-03-2009, 05:40 AM
DonkeyOte Re: Hide command button if... 10-03-2009, 05:42 AM
royUK Re: Hide command button if... 10-03-2009, 05:43 AM
PRodgers4284 Re: Hide command button if... 10-03-2009, 06:03 AM
DonkeyOte Re: Hide command button if... 10-03-2009, 06:09 AM
PRodgers4284 Re: Hide command button if... 10-03-2009, 06:30 AM
PRodgers4284 Re: Hide command button if... 10-05-2009, 04:41 AM
DonkeyOte Re: Hide command button if... 10-05-2009, 04:44 AM
PRodgers4284 Re: Hide command button if... 10-05-2009, 05:03 AM
DonkeyOte Re: Hide command button if... 10-05-2009, 05:31 AM
PRodgers4284 Re: Hide command button if... 10-05-2009, 05:57 AM
PRodgers4284 Re: Hide command button if... 10-05-2009, 07:05 AM
DonkeyOte Re: Hide command button if... 10-05-2009, 07:32 AM
  1. #17
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Hide command button if worksheet is protected

    Again, not sure I follow but just to elaborate in terms of the use of UCase etc...

    By default VBA is case-sensitive unlike native XL, eg

    Public Sub Demo()
    Dim str1 As String, str2 As String
    str1 = "Donkey"
    str2 = "donKey"
    MsgBox str1 = str2
    End Sub
    generates FALSE (whereas in native XL: ="Donkey"="donKey" would generate TRUE)

    on that basis I tend to convert both strings to a common case before comparing so as to remove issue of case sensitivity

    Public Sub DemoTwo()
    Dim str1 As String, str2 As String
    str1 = "Donkey"
    str2 = "donKey"
    MsgBox UCase(str1) = UCase(str2)
    End Sub
    Generates TRUE as DONKEY = DONKEY

    In your case the str1 is the Environ("username") and str2 is your own NT login, so given I am going to coerce str1 to Upper Case I must ensure that the test value is also in Upper Case, ie even if my real NT ID is donKey I would use:

    MsgBox UCase(Environ("username")) = "DONKEY"
    Given my NT login will be forced to Upper Case in the first part of the test.

    You can also use Option Compare Text at the head of a Module to indicate all comparisons should be case insensitive, however, in some cases you may want case sensitivity so I prefer the above method myself as a general rule
    Last edited by DonkeyOte; 10-05-2009 at 07:34 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1