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
Bookmarks