userform multi tab control

DB73

Board Regular
Joined
Jun 7, 2022
Messages
107
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2010
  6. 2007
Platform
  1. Windows
  2. Mobile
  3. 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

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
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
What's the difference between the tabs? A TabStrip might make more sense, or some other means of indicating which of the 8 options should be used by the buttons.
 
Upvote 0
acualy the tabs are the same, only the textbox and the listbox is refering to other tables
the btns are all the same, they do the same job only refering to other cells and tables

as example, the delete button del. the item in the listbox and connected table of that tab , so will the other btns work per tab


what a Tabstrip??
 
Upvote 0
A TabStrip is literally that - a strip of tabs. Like a multipage, but without the pages. ;) You could use its Change event to alter which table the listbox and textbox refer to, so you'd only actually have one set of controls.
 
Upvote 0
for my understanding...im not familiar with all those english terms...its just an userform with all the listboxes and textboxes next to eachother
 
Upvote 0
oh...i found it on utube...its a control....lol...didnt know that...its not in my toolbox....i'll search it up
 
Upvote 0
It's one of the default controls so it should be there in your toolbox - usually before the multipage
 
Upvote 0
It's one of the default controls so it should be there in your toolbox - usually before the multipage
i found it....gonna play with it....
i'm just questioning myself how to make the code for the 4 buttons to work....the btnns need to know on what page i am to work properly

anyway...thanks for the help...learned someting new today.
 
Upvote 0
If you use the tab strip there are no pages, so you simply refer to the one textbox and listbox.
 
Upvote 0
If you use the tab strip there are no pages, so you simply refer to the one textbox and listbox.
so the click event on the , for example, the add btn must have ;

Private Sub ADD btn_click()
Case is = 0
listbox1.rowsource
Case is = 1
listbox2.rowsourse
Case is = 2
listbox3.rowsource

etc.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,435
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top