List All Environment Variables with VBA Environ - wellsr.com

PHOTO EMBED

Mon May 06 2024 21:18:48 GMT+0000 (Coordinated Universal Time)

Saved by @acassell

Sub AllEnvironVariables()
    Dim strEnviron As String
    Dim VarSplit As Variant
    Dim i As Long
    For i = 1 To 255
        strEnviron = Environ$(i)
        If LenB(strEnviron) = 0& Then GoTo TryNext:
        VarSplit = Split(strEnviron, "=")
        If UBound(VarSplit) > 1 Then Stop
        Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Value = i
        Range("B" & Range("B" & Rows.Count).End(xlUp).Row + 1).Value = VarSplit(0)
        Range("C" & Range("C" & Rows.Count).End(xlUp).Row + 1).Value = VarSplit(1)
TryNext:
    Next
End Sub
content_copyCOPY

https://wellsr.com/vba/2019/excel/list-all-environment-variables-with-vba-environ/