Notifications
Clear all
VBA & Macros
4
Posts
4
Users
0
Reactions
27
Views
Topic starter
I have to find max number criteria as combobox
Posted : 12/01/2020 9:03 am
Going to need a bit more info than just that!
Can you add an example worksheet, with an expected outcome?
Purfleet
Posted : 12/01/2020 2:33 pm
You need to use the MAXIFS function and convert your data into a table so you can use structured references rather than address entire columns. See attached workbook.
TextBox1.Value = Application.WorksheetFunction.MaxIfs (Range("Table1[Value]"), Range("Table1[Type]"), ComboBox1.Value)
These posts may help with your userform https://www.myonlinetraininghub.com/tag/userforms
Regards
Phil
Posted : 19/01/2020 8:26 pm
You can make the range Dynamic in the code.
Private Sub ComboBox1_Change() Dim rng As Range, x Set rng = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row) x = Application.WorksheetFunction _ .MaxIfs(rng.Offset(, 1), rng, Me.ComboBox1) If x > 0 Then Me.TextBox1.Value = x + 1 Else Me.TextBox1.Value = 1 End If End Sub
Posted : 20/01/2020 11:43 am