我想做什么
Public Function ClickedSlicerItem(ByRef SlicerOpt1)
Call Slicer_Opt
End Function
Sub Slicer_Opt()
Dim LastMonth As String
Dim MiddleMonth As String
Dim FirstMonth As String
Dim Date1 As Date
Dim MonthMax As String
Dim MinMonth As Date
Dim SlicerMthCache As SlicerCache
Dim SlicerOpt1 As SlicerItem
Date1 = WorksheetFunction.Max(Sheets("Activity Log").Range("H:H"))
MinMonth = WorksheetFunction.Min(Sheets("Activity Log").Range("H:H"))
MonthMax = Month(Date1)
LastMonth = MonthName(MonthMax, True)
MiddleMonth = MonthName(MonthMax - 1, True)
FirstMonth = MonthName(MonthMax - 2, True)
If SlicerOpt1.ActiveItem Is Not Null Then
Application.ScreenUpdating = False
If ActiveWorkbook.SlicerCaches("Slicer_Last_Log_in").SlicerItems(LastMonth).Selected = True Then
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartType = xlBarClustered
ElseIf ActiveWorkbook.SlicerCaches("Slicer_Last_Log_in").SlicerItems(MiddleMonth).Selected = True Then
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartType = xlBarClustered
ElseIf ActiveWorkbook.SlicerCaches("Slicer_Last_Log_in").SlicerItems(FirstMonth).Selected = True Then
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartType = xlBarClustered
End If
Application.ScreenUpdating = True
Else: ActiveChart.ChartType = xlBarStacked100
End If
End Sub
发生了什么
$ echo $USERNAME
myusername
$ export USERNAME=newvalue
$ echo $USERNAME
newvalue
我尝试的内容
$ echo $USERNAME
myusername
$ export USERNAME=newvalue
$ echo $USERNAME
myusername
...; sudo
。有用的笔记
OS:macOS Mojave 10.14
我正在使用unset USERNAME
在发布之前我做了什么
我能够使用zsh
(https://github.com/direnv/direnv)多次更改环境变量,并且一切运行良好。
我能够在direnv
中设置局部环境变量。
然后,我遇到了这个问题...
解决方案
https://unix.stackexchange.com/questions/483469/cannot-change-the-environment-variable
答案 0 :(得分:4)
在zsh中,USERNAME
var很神奇。这不是正常的导出环境变量。在手册页中:
USERNAME <S>
The username corresponding to the real user ID of the shell process. If you
have sufficient privileges, you may change the username (and also the user
ID and group ID) of the shell by assigning to this parameter. Also (assum-
ing sufficient privileges), you may start a single command under a different
username (and user ID and group ID) by `(USERNAME=username; command)'
在其他shell中,例如bash和fish,这不是一个特殊的变量,您可以像设置任何其他env变量一样对其进行设置:
bash$ echo $USERNAME
bash$ export USERNAME=wtf
bash$ echo $USERNAME
wtf