gpt4 book ai didi

vba - Excel VBA - 列出所有 VBA 环境变量

转载 作者:行者123 更新时间:2023-12-04 21:23:03 27 4
gpt4 key购买 nike

如何让 excel 在我的“临时”表上列出所有可用的环境变量?下面的代码没有为我返回任何东西......

Sub ListEnvironVariables()
Dim strEnviron As String
Dim i As Long
For i = 1 To 255
strEnviron = Environ(i)
If LenB(strEnviron) = 0& Then Exit For
Debug.Print strEnviron
Next
End Sub

谢谢

最佳答案

从您的代码中修改了几行,如下所示。

Sub ListEnvironVariables()
Dim strEnviron As String
Dim i As Long
For i = 1 To 255
strEnviron = Environ(i)
If LenB(strEnviron) = 0& Then Exit For
With Worksheets("temp")
.Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Value = strEnviron
End With
Next
End Sub

关于vba - Excel VBA - 列出所有 VBA 环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36441882/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com