Results 1 to 4 of 4

Difference between Environ("USERNAME") and Environ$("USERNAME")

Threaded View

  1. #1
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Difference between Environ("USERNAME") and Environ$("USERNAME")

    I'm even ashamed of asking but what is the difference in using Environ("USERNAME") or Environ$("USERNAME")?

    And from my readings, coders advice to use an "Option Explicit" factor. Why? And where to you put it in your code?

    EDIT: For instance, I deviced the following code from help from all around. I placed a question regarding part of it last week here but no answer, and I needed help on something related on MrExcel, but I figured it already, so I'll advice them shortly:
    Private Sub Workbook_Open()
    Dim UserName As String
    UserName = Environ$("USERNAME")
        Select Case UserName
            Case "bwag", "myo", "dbadalez", "erosa", "msoa"
                x = Sheets("Department1").Columns(2).SpecialCells(2).Address
                ThisWorkbook.Sheets("Summary").ComboBox1.List = Sheets("Department1").Columns(2).SpecialCells(2).Value
            Case "ron2k_1"
                ThisWorkbook.Sheets("Summary").ComboBox1.List = Sheets("Department1").Range("B8:C18").Value
            Case "my_boss"
                ThisWorkbook.Sheets("Summary").ComboBox1.List = Sheets("Department2").Columns(2).SpecialCells(2).Value
        End Select
    End Sub
    As you notice my code is novice, do I need the Option Explicit thingy (or anything else) there? So far it works, so I'm so proud of myself...

    Thanks,
    Last edited by ron2k_1; 02-03-2011 at 05:08 PM.
    Ron
    Knowledge is knowing that a tomato and pepper are fruits. Wisdom is knowing whether to put these in a fruit salad

    Kindly

    [1] Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks
    [2] Mark your post [SOLVED] if it has been answered satisfactorily by editing your original post in advanced mode.
    [3] Thank (using the little scale) those that provided useful help; its nice and its very well appreciated

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