Reputation: 13
I have 15 sheets on an excel file with name Sheet 1 to Sheet 16, I have a button on Sheet 1 when I pressed it will show 10 sheets (Sheet 2 to Sheet 16)
I do some research but couldn't find the best solutions.
Regards.
Upvotes: 0
Views: 222
Reputation: 14373
The code below will randomly select one of the sheets "Sheet2" to Sheet16" when triggered by CommandButton1
on your Sheet1 tab.
Sub Commandbutton1_Click()
Dim RandomNumber As Integer
Randomize
RandomNumber = Int((16 - 2 + 1) * Rnd + 2)
ThisWorkbook.Worksheets("Sheet" & RandomNumber).Select
End Sub
Upvotes: 0
Reputation: 43575
Try running the following code:
Sub TestMe()
ActiveWindow.NewWindow
ActiveWindow.NewWindow
ActiveWindow.NewWindow
ActiveWindow.NewWindow
ActiveWindow.NewWindow
ActiveWindow.NewWindow
ActiveWindow.NewWindow
ActiveWindow.NewWindow
ActiveWindow.NewWindow
ActiveWindow.NewWindow
ActiveWindow.Close
ActiveWindow.WindowState = xlNormal
With ActiveWindow
.Top = 7
.Left = 205
End With
Windows.Arrange ArrangeStyle:=xlVertical
End Sub
It will show 10 times the active sheet, vertically. Then you only have to find a way to show the needed one per active window.
Upvotes: 1