VBA 根据活动工作表激活用户窗体选项卡
VBA Activate Userform Tab depending on active worksheet
我有一个用户表单,其中包含许多与特定工作表相关的选项卡。我正在尝试根据初始化用户窗体时活动工作表的内容来激活特定选项卡。有人可以帮助我吗?
谢谢。
Private Sub UserForm_Initialize()
If ActiveSheet.Name = "Test1" Then
MultiPageSheets.SelectedItem.Index = 0
ElseIf ActiveSheet.Name = "Test2" Then
MultiPageSheets.SelectedItem.Index = 1
ElseIf ActiveSheet.Name = "Test3" Then
MultiPageSheets.SelectedItem.Index = 2
ElseIf ActiveSheet.Name = "Test4" Then
MultiPageSheets.SelectedItem.Index = 3
End If
End Sub
尝试:
Private Sub UserForm_Initialize()
If ActiveSheet.Name = "Test1" Then
MultiPageSheets.Value = 0
ElseIf ActiveSheet.Name = "Test2" Then
MultiPageSheets.Value = 1
ElseIf ActiveSheet.Name = "Test3" Then
MultiPageSheets.Value = 2
ElseIf ActiveSheet.Name = "Test4" Then
MultiPageSheets.Value = 3
End If
End Sub
我有一个用户表单,其中包含许多与特定工作表相关的选项卡。我正在尝试根据初始化用户窗体时活动工作表的内容来激活特定选项卡。有人可以帮助我吗?
谢谢。
Private Sub UserForm_Initialize()
If ActiveSheet.Name = "Test1" Then
MultiPageSheets.SelectedItem.Index = 0
ElseIf ActiveSheet.Name = "Test2" Then
MultiPageSheets.SelectedItem.Index = 1
ElseIf ActiveSheet.Name = "Test3" Then
MultiPageSheets.SelectedItem.Index = 2
ElseIf ActiveSheet.Name = "Test4" Then
MultiPageSheets.SelectedItem.Index = 3
End If
End Sub
尝试:
Private Sub UserForm_Initialize()
If ActiveSheet.Name = "Test1" Then
MultiPageSheets.Value = 0
ElseIf ActiveSheet.Name = "Test2" Then
MultiPageSheets.Value = 1
ElseIf ActiveSheet.Name = "Test3" Then
MultiPageSheets.Value = 2
ElseIf ActiveSheet.Name = "Test4" Then
MultiPageSheets.Value = 3
End If
End Sub