Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,064
- Office Version
- 2016
- Platform
- Windows
I am trying to update a listbox on a userform every few seconds. I have two examples on the attached sheet, The first example has the listbox on the userform without any multipages and nested multipages, this works fine. I am now trying to build one that will work when the right TAB of a multipage is selected, but can not work it out.
DOWNLOAD LINK Here
IN THE SECOND EXAMPLE
I have attached a quick example of what I am trying to do on the download. The listbox is on a USERFORM, the form has Multipages and NESTED Multipages. You will first need to navigate to Multipage1.pages (2) and then the nested Multipage2.PAGES (4). There you will see the listbox and a STOP button.
What the code should do.
When the user has navigated to the right tab, the code should AUTO RUN. The code updates the listbox every 5 seconds, with the data that goes into to sheet1, when the stop button is clicked, the listbox stops updating. The code SHOULD NOT update THE LISTBOX as the data goes into the sheet, It should ONLY update after a set amount of seconds e.g. 5 seconds.
Error I keep getting
DOWNLOAD LINK Here
IN THE SECOND EXAMPLE
I have attached a quick example of what I am trying to do on the download. The listbox is on a USERFORM, the form has Multipages and NESTED Multipages. You will first need to navigate to Multipage1.pages (2) and then the nested Multipage2.PAGES (4). There you will see the listbox and a STOP button.
What the code should do.
When the user has navigated to the right tab, the code should AUTO RUN. The code updates the listbox every 5 seconds, with the data that goes into to sheet1, when the stop button is clicked, the listbox stops updating. The code SHOULD NOT update THE LISTBOX as the data goes into the sheet, It should ONLY update after a set amount of seconds e.g. 5 seconds.
VBA Code:
Private Sub MultiPage2_Layout(ByVal Index As Long)
If MultiPage2.Pages(4).Value = True Then
'data of worksheet
With UserForm2.ListBox1
.ColumnCount = 3
.ColumnWidths = "200;100;100"
.RowSource = "'" & Sheet1.Name & "'!$A$1:$c$" & Sheet1.Cells(Sheet1.Rows.Count, 1).End(xlUp).Row
'update listbox every 5 seconds
UpdateListBoxes
t = DateAdd("s", 5, Time) ' Change the 5 seconds to suit your needs.
Application.OnTime t, "StartThem"
End With
End If
End Sub
Error I keep getting