我正在尝试从gui Farzeug
内修改我的popupmenu
结构。我正在尝试使用assignin
函数。
contents = get(hObject,'Value')
Klima_Regler_GUI = evalin('base','Fahrzeug.Klima_Regler');
switch contents
case 1
Klima_Regler_GUI = 1;
assignin('base','Fahrzeug.Klima_Regler',Klima_Regler_GUI);
case 2
Klima_Regler_GUI = 0.75;
assignin('base','Fahrzeug.Klima_Regler',Klima_Regler_GUI);
case 3
Klima_Regler_GUI = 0.50;
assignin('base','Fahrzeug.Klima_Regler',Klima_Regler_GUI);
case 4
Klima_Regler_GUI= 0.25;
assignin('base','Fahrzeug.Klima_Regler',Klima_Regler_GUI);
case 5
Klima_Regler_GUI = 0;
assignin('base','Fahrzeug.Klima_Regler',Klima_Regler_GUI);
otherwise
但我一直收到这个错误:
我将不胜感激任何帮助
答案 0 :(得分:0)
使用Option Explicit
Sub Sort_database()
Dim i As Long
Dim lastCol As Long, counter As Double
For i = 2 To 14
With Worksheets(i) '<--| reference i-th sheet
lastCol = GetLastCol(.Cells(30, 4)) '<--| get currently reference worksheet last column rightwards of its cell "D30"
For counter = 4 To lastCol
.Cells(78, counter) = WorksheetFunction.Sum(.Range(.Cells(31, counter), .Cells(77, counter))) '<--| use 'SUM()' built in Worksheet function
Next counter
.Range("M2").Value = WorksheetFunction.Sum(.Range(.Cells(78, 4), .Cells(78, lastCol))) '<-- '<--| use 'SUM()' built in Worksheet function and write its result in cell "M2" of currently referenced worksheet
End With
Next i
End Sub
Function GetLastCol(rng As Range) As Long
GetLastCol = IIf(rng.End(xlToRight).Value = "", rng.Column, rng.End(xlToRight).Column)
End Function
无法更改结构字段,因为
assignin(ws,'var',val)将值val赋给工作空间ws中的变量var。 var输入必须只是数组名称;它不能包含数组索引。
但您可以使用assignin
执行此操作:
evalin