我有一个包含100多个工作表并命名为1,2,3等的文件夹,但我只能通过将.xlsx
添加到组合框中的工作簿编号来打开工作簿。
有办法解决这个问题吗?
Private Sub CommandButton1_Click()
Dim filename As String
Dim filepath As String
filename = ComboBox1.Value
filepath = "D:\e-library\MSC\DIS7000\data\"
Workbooks.Open (filepath & filename)
End Sub
答案 0 :(得分:0)
是的 - 您可以通过编程方式而不是手动将.xlsx
添加到文件名。
试试这个:
Private Sub CommandButton1_Click()
Dim filename As String
Dim filepath As String
filename = ComboBox1.Value
filepath = "D:\e-library\MSC\DIS7000\data\"
Workbooks.Open (filepath & filename & ".xlsx")
End Sub