简体   繁体   English

Excel2010 / VBA:用户窗体会话期间工作表变量的存储和使用

[英]Excel2010/VBA: Store and Usage of Worksheet Variable during Userform Session

Hello and excuse my bumpy English. 您好,请原谅我坎English的英语。

  • In Worksheet1 is a button who is calling a Userform 在Worksheet1中是一个正在调用用户窗体的按钮
  • I want to Use the current Worksheet during the Userform Session but im not able to use this... 我想在用户窗体会话期间使用当前工作表,但无法使用此工作表...
  • I want to Use a variable for further usage. 我想使用一个变量作进一步的使用。
  • The Button on Worksheet1 is Calling this Macro Worksheet1上的按钮正在调用此宏

  Option Explicit Public GlbVarBaseSheet As String ------------ Sub Formularaufruf_Worksheet1() GlbVarBaseSheet = ActiveSheet.Name with Userform1 .MultiPage1.Value = 1 .Show 0 End With End Sub 

Within the Userform, there´sa Sub Called Uebernahme, wich fills out the Textboxes reading the column number wich is stored in the .tag of the TextBox. 在用户窗体中,有一个名为Uebernahme的子文件夹,该文件夹将填充文本框,读取的列号将存储在文本框的.tag中。

How can i Use the Worksheet Variable in this line to use is during the Userform Session: This is not working and i don´t know why 我如何在用户窗体会话期间在此行中使用工作表变量:这不起作用,我不知道为什么

 With Workbooks("KVP.xlsm").Worksheets(GlbVarBaseSheet) 

The Full Sub: 完整子:

 Sub Uebernahme() Dim Zeilenindex As Long Dim OBcB As MSForms.Control Dim VarTypeName As String Sheets(GlbVarBaseSheet).Activate ' ' ' Workbooks("KVP.xlsm").ActiveSheet.Rows(spinbutton1.Value).Activate Zeilenindex = spinbutton1.Value ' ' With Workbooks("KVP.xlsm").Worksheets(GlbVarBaseSheet) If .Cells(ActiveCell.Row, 1).Value <> "" Then For Each OBcB In MultiPage1.SelectedItem.Controls VarTypeName = TypeName(OBcB) If OBcB.Tag <> "" Then Select Case VarTypeName Case Is <> "Checkbox" 'OBcB.Value = .cells(Left(OBcB.Tag, 1) & ActiveCell.Row) OBcB.Value = .Cells(ActiveCell.Row, Int(Left(OBcB.Tag, 1))).Value End Select End If Next End If End With End Sub 

Thanks in advance 提前致谢

尝试

dim GlbVarBaseSheet as Worksheet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM