MarcelCleijsen
New Member
- Joined
- Feb 15, 2016
- Messages
- 7
I have created an excel userform with some comboboxes, attached a document with the problem but stripped down to the basic problem.
I figured out how i can filter/autoupdate my comboboxes and decrease the input list while i start typing in the list. However as soon as i select an item i get the following error: "Unable to get the CurrentRegion property of the Range class". I have tried many different solutions to get rid of the problem. But still can not figure out this final error. Even when I try to use "Range" instead of "CurrentRegion" I get these errors.
Since i want to apply this feature to all comboboxes on my userforms i have put everything in a class event.
I have already found some stuff online but these were basically comboboxes on a worksheet. I like to actively update the data on a userform. I think I have applied all stuff I found online in the code which I now have, but still need to solve this final issue. Until now all my solutions crashed.
this is my example file
Thank you very much!
Best Regards, Marcel
I figured out how i can filter/autoupdate my comboboxes and decrease the input list while i start typing in the list. However as soon as i select an item i get the following error: "Unable to get the CurrentRegion property of the Range class". I have tried many different solutions to get rid of the problem. But still can not figure out this final error. Even when I try to use "Range" instead of "CurrentRegion" I get these errors.
Since i want to apply this feature to all comboboxes on my userforms i have put everything in a class event.
I have already found some stuff online but these were basically comboboxes on a worksheet. I like to actively update the data on a userform. I think I have applied all stuff I found online in the code which I now have, but still need to solve this final issue. Until now all my solutions crashed.
this is my example file
Thank you very much!
Best Regards, Marcel
Code:
Option Explicit
Public WithEvents myCBox As msForms.ComboBox
Dim data As Range
Private Sub myCBox_Change()
Set data = filter.Cells(1, 1).CurrentRegion
' filter.Activate
With myCBox
.DropDown
' FILTER
list.Cells(1, 1).CurrentRegion.AutoFilter Field:=1, Criteria1:="*" & .Value & "*"
' COPY
filter.Cells.Clear
list.Cells(1, 1).CurrentRegion.Copy Destination:=filter.Cells(1, 1)
Set data = filter.Cells(1, 1).CurrentRegion
num_rows_2 = data.Rows.Count
' UPDATE COMBOBOX
.RowSource = "filter!A2:A" & num_rows_2
End With
End Sub