Option Explicit
Private Sub CommandButton1_Click()
Dim oTab As MSForms.Tab
'Your code here
'
'
With Me.TabStrip1
If .Value < .Tabs.Count - 1 Then 'the active tab isn't the last tab
For Each oTab In .Tabs
oTab.Enabled = True
Next oTab
.Value = .Value + 1 'go to the next tab
Call UpdateTabStrip(Me.TabStrip1)
End If
End With
End Sub
Private Sub UserForm_Initialize()
Dim oTab As MSForms.Tab
Me.TabStrip1.Value = 0 'make sure the first tab is active when the form is shown
Call UpdateTabStrip(Me.TabStrip1)
End Sub
Private Sub UpdateTabStrip(oTabStrip As MSForms.TabStrip)
Dim oTab As MSForms.Tab
For Each oTab In oTabStrip.Tabs
If oTab.Index <> oTabStrip.Value Then
oTab.Enabled = False
End If
Next oTab
End Sub
Private Sub UserForm_Initialize()
Dim c As Excel.Range
Dim t As Object
'With cbxRooms
' .ColumnCount = 2
' .ColumnWidths = "135,135"
' .List = Range("Room2").Value
'End With
Me.tsWood.Value = -1 'tabstrip no index start
Do While tsWoodRun.Tabs.Count > 1
tsWoodRun.Tabs.Remove (1) 'remove all but first tab
Loop
For Each c In Worksheets("Lists").Range("Doors")
If c.Value <> vbNullString Then 'if range value not ""
Set t = tsWoodRun.Tabs.Add 'create new tab
t.Caption = c.Text 'name tab
End If
Next
ufRooms.tsWoodRun.Tabs.Remove (0) 'tabstrip remove 1st tab after populating captions
Me.tsWoodRun.Value = -1
End Sub
Private Sub tsWood_Change() 'tabstrip wood runtime nameranges
Dim varTab As Variant
Dim r As String
varTab = ufRooms.tsWood.Value
If Me.tsWood.Value = -1 Then
Me.fWood.Visible = False: GoTo fit
ElseIf Me.tsWood.Value >= 0 Then
Me.fWood.Visible = True
End If
r = ufRooms.tsWood.SelectedItem.Caption
Do While tsWoodRun.Tabs.Count > 1
tsWoodRun.Tabs.Remove (1)
Loop
Select Case varTab
Case Is = 0, 1, 2, 3
For Each c In Worksheets("Lists").Range(r)
If c.Value <> vbNullString Then
Set t = tsWoodRun.Tabs.Add
t.Caption = c.Text
End If
Next
End Select
ufRooms.tsWoodRun.Tabs.Remove (0)
Me.tsWoodRun.Value = -1
fit:
End Sub
Private Sub tsWoodRun_Click(ByVal Index As Long)
Me.tbxWoodQuant.SetFocus
End Sub
Option Explicit
Private Sub cbWoodReturn_Click()
Dim oTab As MSForms.Tab
'Your code here
'
'
With Me.tsWoodRun
If .Value < .Tabs.Count - 1 Then 'the active tab isn't the last tab
For Each oTab In .Tabs
oTab.Enabled = True
Next oTab
.Value = .Value + 1 'go to the next tab
Call EnableTabStrip(Me.tsWoodRun)
End If
.Value = -1
End With
End Sub
Private Sub UpdateTabStrip(oTabStrip As MSForms.TabStrip)
Dim oTab As MSForms.Tab
For Each oTab In oTabStrip.Tabs
If oTab.Index <> oTabStrip.Value Then
oTab.Enabled = False
End If
Next oTab
End Sub
Private Sub EnableTabStrip(oTabStrip As MSForms.TabStrip)
Dim oTab As MSForms.Tab
For Each oTab In oTabStrip.Tabs
If oTab.Index <> oTabStrip.Value Then
oTab.Enabled = True
End If
Next oTab
End Sub
Private Sub UserForm_Initialize()
Dim oTab As MSForms.Tab
' Me.TabStrip1.Value = 0 'make sure the first tab is active when the form is shown
Call UpdateTabStrip(Me.tsWoodRun)