Adding a filter and combobox to a toggling form

Milandra

New Member
Joined
Aug 31, 2016
Messages
3
In the last 3 months I have been trying to get more familiar with Excel and every time I Google any question I may have it always brings me here and I almost always find what I'm looking for so thank you everyone that contributes to this site.

I feel bad for asking since I'm a novice and don't have much knowledge to contribute but I was hoping for some help. I've been trying to modify a free user form I found online to better suit my purposes. The user form searches the first column of my spreadsheet and returns the data on that on that row based on what's entered in a textbox and then allows you to toggle up or down from the result between records. The search feature works fine but all the identifiers need to be unique. I'd like to instead have the search feature filter and only give results that match the search criteria regardless of the values in the first column being unique or not. But more importantly I need to add a combobox to add information to the last column of the row you're currently viewing. Any help would be appreciated. I'll leave a link to the file on Google Drive and the code below.

https://drive.google.com/open?id=0BxJ8xb0y2VlETlBnVnIwZFF5RjQ

Private Sub cmdClose_Click()
'close the userform
Unload Me
End Sub
Private Sub cmdSearch_Click()
'declare the variables
Dim FindRow
Dim i As Integer
Dim cRow As String


'error block
On Error GoTo errHandler:


'find the row with the data
cRow = Me.txtsearch.Value
Set FindRow = Sheet1.Range("C:C").Find(What:=cRow, LookIn:=xlValues)


'add the values to the userform
Me.control1.Value = FindRow
Me.control2.Value = FindRow.Offset(0, 1)
Me.control3.Value = FindRow.Offset(0, 2)
Me.control4.Value = FindRow.Offset(0, 3)
Me.control5.Value = FindRow.Offset(0, 4)
Me.control6.Value = FindRow.Offset(0, 5)


'error block
On Error GoTo 0
Exit Sub
errHandler:
MsgBox "Error! Check you have typed the data correctly " & vbCrLf & Err.Description
End Sub


Private Sub CmndSubmit_Click()


End Sub


Private Sub ComboBox1_Change()


End Sub




Private Sub ToggleButton1_Click()
'declare the variables
Dim FindRow
Dim i As Integer
Dim cRow As String


'error block
On Error Resume Next


'find the row with the data and move up one row
cRow = Me.control1.Value
Set FindRow = Sheet1.Range("C:C").Find(What:=cRow, LookIn:=xlValues).Offset(-1, 0)
If FindRow.Value = Sheet1.Range("C4").Value Then Exit Sub
Me.txtsearch = FindRow.Value
'add the values to the userform with a loop
cNum = 6
For x = 1 To cNum
Me.Controls("Control" & x).Value = FindRow '.Offset(1, 0)
Set FindRow = FindRow.Offset(0, 1)
Next
'error block
On Error GoTo 0


End Sub
Private Sub ToggleButton2_Click()
'declare the variables
Dim FindRow
Dim i As Integer
Dim cRow As String


'error block
On Error Resume Next


'find the row with the data and move down one row
cRow = Me.control1.Value
Set FindRow = Sheet1.Range("C:C").Find(What:=cRow, LookIn:=xlValues).Offset(1, 0)
If FindRow.Value = "" Then Exit Sub
Me.txtsearch = FindRow.Value
'add the values to the userform with a loop
cNum = 6
For x = 1 To cNum
Me.Controls("Control" & x).Value = FindRow '.Offset(1, 0)
Set FindRow = FindRow.Offset(0, 1)
Next


'error block
On Error GoTo 0


End Sub


Private Sub UserForm_Click()


End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I came up with this but it won't add the data to row I'm viewing.

Private Sub CmndSubmit_Click()


Dim ws As Worksheet
Set ws = Worksheets("toggle")


Dim newRow As Long
newRow = Application.WorksheetFunction.CountA(ws.Range("a:a")) + 1


ws.Cells(newRow, 1).Value = Me.ComboBox1.Value


End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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