如果 Userform Multipage Sheet 处于活动状态,则执行函数

If Userform Multipage Sheet Is active, then execute function

我试图让用户窗体将活动多页的名称 sheet 拉到我工作簿中的特定列。用户窗体中有 4 个页面,其中包含输入工作簿的选项按钮。选项按钮数据已经正确提交。

我需要页面名称,以便对选项按钮结果进行分类。以下是我尝试过的一些方法。

  1. If Page1.Page.Value = 0 Then
       x.Cells(nextRow, 4) = "Category 1"
    End IF
    
  2. If Page1.Value = True Then
       x.Cells(nextRow, 4) = "Category 1"
    End IF
    
  3. If Page1.Value = True Then
       x.Cells(nextRow, 4) = Me.Page1.Caption
    End IF
    

有什么建议吗?

考虑使用 SelectedItem 属性 的标题来获取活动页面的名称:

If MultiPage1.SelectedItem.Caption = "myPageName" Then
   x.Cells(nextRow, 4) = "needed value"
End IF

或者如果您希望单元格值指向当前的多页名称,则简洁:

x.Cells(nextRow, 4) = MultiPage1.SelectedItem.Caption

在 MultiPages object 上查看此信息 tutorial