我用以下代码创建了一个名为EnergyPrice的函数:
这是我正在寻找的价格
Prijstabel
fixed variable
Startdate Einddate gas electra gas electra
€/a €/a ct/KWh ct/KWh
1-1-2010 1-7-2010 181,00 235,00 0,11 0,33
1-7-2010 1-1-2011 362,00 470,00 0,33 1,30
1-1-2011 1-7-2011 191,00 245,00 0,22 0,65
1-7-2011 1-1-2012 162,35 208,25 0,19 0,55
1-1-2012 1-7-2012 324,70 416,50 0,37 1,11
Run Code Online (Sandbox Code Playgroud)
这是相关的代码
Public Enum Energietype
v_gas = 1
v_electricity = 2
End Enum
Public Enum FixedOrVariable
v_fixed = 1
v_variable = 2
End Enum
Public Function EnergyPrice(PriceDate As Date, E_type As Energietype, variabel As FixedOrVariable) As …Run Code Online (Sandbox Code Playgroud) 我正在尝试从数据单元接受格式化常量,所以我有一个字符串"xlTotalsCalculationAverage".如何将其转换为它所代表的Excel常量; 常量xlTotalsCalculationAverage等于整数2.
ActiveSheet.ListObjects(1).ListColumns(RemainingHeader).TotalsCalculation = xlTotalsCalculationAverage
Run Code Online (Sandbox Code Playgroud)
是一个静态表示.
TargetTotal = something("xlTotalsCalculationAverage")
ActiveSheet.ListObjects(1).ListColumns(RemainingHeader).TotalsCalculation = TargetTotal
Run Code Online (Sandbox Code Playgroud)
是我的目标.
我可以创建一个巨大的case或switch语句,但复制所有可能的值似乎很愚蠢.
如何让Excel将此字符串转换为已知的常量值?