Hi please consult.
I have a UserForm and a Combobox interface. There are conditions in the ComboBox. which when they come true. TextBox appears in the frame.
The problem is the one. that when you return in terms of conditions. Frames overlap. How to fix it? A snippet is attached.
I have a UserForm and a Combobox interface. There are conditions in the ComboBox. which when they come true. TextBox appears in the frame.
The problem is the one. that when you return in terms of conditions. Frames overlap. How to fix it? A snippet is attached.
Code:
Private Sub slpceDH()
'Sloupec D:H
Dim TBD As MSForms.TextBox
Dim lbD As MSForms.Label
Set NewFrameDH = Me.Controls.Add("Forms.Frame.1")
Set lbD = NewFrameDH.Controls.Add("Forms.Label.1")
Set lbE = NewFrameDH.Controls.Add("Forms.Label.1")
Set lbF = NewFrameDH.Controls.Add("Forms.Label.1")
Set lbG = NewFrameDH.Controls.Add("Forms.Label.1")
Set lbH = NewFrameDH.Controls.Add("Forms.Label.1")
Set TBD = NewFrameDH.Controls.Add("Forms.TextBox.1")
Set TBE = NewFrameDH.Controls.Add("Forms.TextBox.1")
Set TBF = NewFrameDH.Controls.Add("Forms.TextBox.1")
Set TBG = NewFrameDH.Controls.Add("Forms.TextBox.1")
Set TBH = NewFrameDH.Controls.Add("Forms.TextBox.1")
'Začátek scrollbaru
'With NewFrameDG
'.ScrollBars = fmScrollBarsVertical
'Change 8.5 to suit your needs
'.ScrollHeight = .InsideHeight * 8.5
'.ScrollWidth = .InsideWidth * 9
'End With
'Konec scrollbaru
NewFrameDH.Top = 30
NewFrameDH.Left = 6 ' from the left border of frame1
NewFrameDH.Caption = "Sloupce D:F"
NewFrameDH.Height = 120
NewFrameDH.Width = 139
lbD.Top = 13
lbD.Left = 5
lbD.Caption = "Sloupec D: "
TBD.Top = 10
TBD.Left = 47
lbE.Top = 33
lbE.Left = 5
lbE.Caption = "Sloupec E: "
TBE.Top = 30
TBE.Left = 47
lbF.Top = 53
lbF.Left = 5
lbF.Caption = "Sloupec F: "
TBF.Top = 50
TBF.Left = 47
lbG.Top = 73
lbG.Left = 5
lbG.Caption = "Sloupec G: "
TBG.Top = 70
TBG.Left = 47
lbH.Top = 93
lbH.Left = 5
lbH.Caption = "Sloupec H: "
TBH.Top = 90
TBH.Left = 47
If rozsah.Value = "D4:H4" Then
NewFrameDH.Visible = True
Else
NewFrameDH.Visible = False
End If
End Sub
Private Sub rozsah_Change()
If rozsah.Value = "D4:E4" Then Call slpceDE
If rozsah.Value = "D4:F4" Then Call slpceDF
If rozsah.Value = "D4:G4" Then Call slpceDG
If rozsah.Value = "D4:H4" Then Call slpceDH
End Sub
Private Sub ulozit_Click()
On Error GoTo EndSub
ActiveSheet.ListObjects.Add(xlSrcRange, Range(rozsah.Value), , xlYes).Name = "Tabulka"
Unload Me
EndSub: End Sub
Private Sub UserForm_Initialize()
With rozsah
.AddItem "D4:E4"
.AddItem "D4:F4"
.AddItem "D4:G4"
.AddItem "D4:H4"
.AddItem "D4:I4"
.AddItem "D4:J4"
.AddItem "D4:K4"
.AddItem "D4:L4"
.AddItem "D4:M4"
.AddItem "D4:N4"
.AddItem "D4:O4"
.AddItem "D4:P4"
.AddItem "D4:Q4"
.AddItem "D4:R4"
.AddItem "D4:S4"
.AddItem "D4:T4"
.AddItem "D4:U4"
.AddItem "D4:V4"
End With
End Sub