Need a way to sort through already entered data via my userform.

kccushman

New Member
Joined
Jun 20, 2017
Messages
13
So I have a userform that populates a table, but I would really like two things added to my userform. First, I'd like it to be able to move between the entries via "prev" and "next" buttons. Then I'd like a way to open a specific entry of data. Anyone have suggestions or ideas of how to go about that and the code they'd use?

I'm very junior in my excel vba and userform experience, so any help would be greatly appreciated.

Thank you! :)
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hey there kccushman,

So first off, when you say you want to move between entries do you mean through a Combo box in the userform? Or when you say userform, are you using userform components on an excel sheet - you want buttons to move up and down the table.

I'm basing my reply off the former (move between entires in a combo box), so let me know if I was mistaken. Here is how to use 2 buttons to move to the next item and the previous item for a ComboBox:

Code:
Private Sub UserForm_Activate()
    Dim i As Integer         'integer used to fill the ComboBox
    Dim n As Integer        'The number of rows in your table
    
    'code for finding n
    
    For i = 1 To n
        UserForm1.ComboBox1.AddItem Worksheets("Sheet1").Cells(i, 1)
    Next i
End Sub


Private Sub NextButton_Click()
    Dim a As Integer


    a = UserForm1.ComboBox1.ListIndex
    If a > n - 2 Then
    Else
        UserForm1.ComboBox1.ListIndex = UserForm1.ComboBox1.ListIndex + 1
    End If
End Sub


Private Sub PrevButton_Click()
    Dim a As Integer


    a = UserForm1.ComboBox1.ListIndex
    If a < 1 Then
    Else
        UserForm1.ComboBox1.ListIndex = UserForm1.ComboBox1.ListIndex - 1
    End If
End Sub
 
Upvote 0
Sorry for the delayed reply! That's great, but it's the bottom one. I have a userform that has a combination of comboboxes, text boxes, radio buttons, etc. that feed into a master excel spreadsheet. From there, I would love to be able to do two things. First, scroll through previous entries in the userform from a previous and next button. then, I'd like a search or find box or a way to select one of the rows entries to open that data into the userform. Does that help?
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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