Trusted Members
December 20, 2019
October 5, 2010
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
Answers Post
December 21, 2018
You can make the range Dynamic in the code.
[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
[/code]
1 Guest(s)