How do I determine what key was pressed
I have a sheet, the user has the option to filter the rows or see all rows.
If the user filters the rows I want my combo box to jump to the next visible
row. I must keep up with the selected value's row, because my code will
update other cells on the selected row.
If I type in the value, I only want the next visible cell value to show.
If I press the down key, I want the next visible cell value to show.
If I press the up key, I want the previous visible cell value to show.
Here's my code (it only works in one direction and it shows one hidden row
on the form before it shows the next visible row. If I press the up arrow, it
doesnt reverse search for the next visible row.)
Private Sub ComboBox1_Change()
Get_Next_Visible_Row
Userform.Show
End Sub
Private Sub Get_Next_Visible_Row()
ActiveCell.Offset(0, 0).Select
If ActiveCell.EntireRow.Hidden Then
i = UserForm2.ComboBox1.ListIndex
On Error Resume Next
Do While ActiveCell.EntireRow.Hidden
ActiveCell.Offset(1, 0).Select
i = i + 1
Loop
UserForm2.ComboBox1.ListIndex = i - 1
End If
End Sub
|