DB73
Board Regular
- Joined
- Jun 7, 2022
- Messages
- 107
- Office Version
- 365
- 2021
- 2019
- 2016
- 2010
- 2007
- Platform
- Windows
- Mobile
- Web
Maybe a silly question but i was thinkeng while i'm tryin to make a userform with a multi tab control
on each tab i have (8 tabs)
1 textbox
1 listbox
4 cmd buttons (add, clear, delete and renew)
so, now im coding 8x4 cmd btns wat do the same thing on every tab
isnt it much easier to put just the 4 cmdbtns on the userform and not on the tabs ?
this is what i use now, but then X8
my guess it is possible, but i dont know how to code it that the buttons comunicate with the "open" tab.
anyone a sugestion or a little help so i can try
on each tab i have (8 tabs)
1 textbox
1 listbox
4 cmd buttons (add, clear, delete and renew)
so, now im coding 8x4 cmd btns wat do the same thing on every tab
isnt it much easier to put just the 4 cmdbtns on the userform and not on the tabs ?
this is what i use now, but then X8
VBA Code:
'add button1
Private Sub CommandButton2_Click()
With Me.MultiPage1.Pages(0)
If Me.TextBox1.value = NullString Then
MsgBox ("Empty values not allowed")
Exit Sub
End If
Sheets("lijsten").Range("AD" & Rows.Count).End(xlUp).Offset(1, 0).value = TextBox1.Text
ListBox1.List = Sheets("lijsten").ListObjects("tabel16").DataBodyRange.Value2
MsgBox ("list is updated")
End With
End Sub
'update button1
Private Sub CommandButton3_Click()
With Me.MultiPage1.Pages(0)
Dim oVal As Long
If Me.TextBox1.value = NullString Then
MsgBox ("Empty values not allowed")
Exit Sub
End If
oVal = Me.ListBox1.ListIndex + 1
Range("Tabel16").Cells(oVal, 1).value = Me.TextBox1.value
ListBox1.List = Sheets("lijsten").ListObjects("tabel16").DataBodyRange.Value2
MsgBox ("list is updated")
End With
End Sub
'empty button1
Private Sub CommandButton4_Click()
With Me.MultiPage1.Pages(0)
TextBox1.Text = ""
End With
End Sub
'delete button1
Private Sub CommandButton5_Click()
With Me.MultiPage1.Pages(0)
Dim i As Integer
Answer = MsgBox("are you sure to remove item from the list ?", vbQuestion + vbYesNo)
If Answer = vbYes Then
On Error Resume Next
Sheets("lijsten").Range("AD:i").Find(ListBox1.value).Delete Shift:=xlUp
ListBox1.List = Sheets("lijsten").ListObjects("tabel16").DataBodyRange.Value2
MsgBox ("list is updated")
End If
End With
End Sub
my guess it is possible, but i dont know how to code it that the buttons comunicate with the "open" tab.
anyone a sugestion or a little help so i can try