View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Environment Variable Names

Run the following code. It will but the name of the environ
variable in column A and the value in column B.

Sub ListEnvioron()
Dim Rng As Range
Dim Ndx As Long
Dim S As String
Dim Pos As Long

Ndx = 1
On Error Resume Next
Set Rng = Range("A1")
Do While True
S = Environ(Ndx)
If Err.Number < 0 Then
Exit Do
End If
Pos = InStr(1, S, "=")
Rng.Value = Left(S, Pos - 1)
Rng(1, 2).Value = Mid(S, Pos + 1)
Ndx = Ndx + 1
Set Rng = Rng(2, 1)
Loop
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Chaplain Doug" wrote in
message
...
Excel 2003. I am using the Environ function to return the
"UserName"
environment variable (i.e., Environ("UserName")). Where would
I find a
listing of the other environment variables avaiable for use
with the Environ
function? Or put another way, what other environment variables
can I use
with the Environ function? Thanks and God bless.
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org