Forum

Find max value crit...
 
Notifications
Clear all

Find max value criteria as combobox

4 Posts
4 Users
0 Reactions
158 Views
(@khatikvasim13)
Posts: 24
Eminent Member
Topic starter
 

I have to find max number criteria as combobox 

 
Posted : 12/01/2020 9:03 am
(@purfleet)
Posts: 412
Reputable Member
 

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
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

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
(@davesexcel)
Posts: 6
Active Member
 

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
Share: