Hi !!
I am having some problems with this macro I am working on. I am trying to look in a Database what is the maximum number in a column that matches 3 variables (2 in combo boxes = student name and module name, and one is a write in as you see in the example bronze). This max value should show up in a textbox inside a userform when the combo boxes are changed. PLEASE help I have tried everything.
'Automatically input maximum level reached based on the student, module name, and ribbon type entered
Dim d As Long
Dim LastRows As Long
Dim wss As Worksheet
Set wss = Sheets("DataBase")
LastRows = wss.Range("A" & Rows.Count).End(xlUp).Row
For d = 2 To LastRows
If wss.Cells(i, "C").Value = (Me.ComboBox2) And wss.Cells(i, "F").Value = (Me.ComboBox7) And wss.Cells(i, "G").Value = "Bronze" Or _
wss.Cells(i, "C").Value = Val(Me.ComboBox2) And wss.Cells(i, "F").Value = Val(Me.ComboBox7) And wss.Cells(i, "G").Value = "Bronze" Then
Me.TextBox10 = wss.Cells(i, "H").Value
End If
If wss.Cells(i, "C").Value = (Me.ComboBox2) And wss.Cells(i, "F").Value = (Me.ComboBox7) And wss.Cells(i, "G").Value = "Silver" Or _
wss.Cells(i, "C").Value = Val(Me.ComboBox2) And wss.Cells(i, "F").Value = Val(Me.ComboBox7) And wss.Cells(i, "G").Value = "Silver" Then
Me.TextBox12 = wss.Cells(i, "H").Value
End If
If wss.Cells(i, "C").Value = (Me.ComboBox2) And wss.Cells(i, "F").Value = (Me.ComboBox7) And wss.Cells(i, "G").Value = "Gold" Or _
wss.Cells(i, "C").Value = Val(Me.ComboBox2) And wss.Cells(i, "F").Value = Val(Me.ComboBox7) And wss.Cells(i, "G").Value = "Gold" Then
Me.TextBox11 = wss.Cells(i, "H").Value
End If
Next d
I am having some problems with this macro I am working on. I am trying to look in a Database what is the maximum number in a column that matches 3 variables (2 in combo boxes = student name and module name, and one is a write in as you see in the example bronze). This max value should show up in a textbox inside a userform when the combo boxes are changed. PLEASE help I have tried everything.
'Automatically input maximum level reached based on the student, module name, and ribbon type entered
Dim d As Long
Dim LastRows As Long
Dim wss As Worksheet
Set wss = Sheets("DataBase")
LastRows = wss.Range("A" & Rows.Count).End(xlUp).Row
For d = 2 To LastRows
If wss.Cells(i, "C").Value = (Me.ComboBox2) And wss.Cells(i, "F").Value = (Me.ComboBox7) And wss.Cells(i, "G").Value = "Bronze" Or _
wss.Cells(i, "C").Value = Val(Me.ComboBox2) And wss.Cells(i, "F").Value = Val(Me.ComboBox7) And wss.Cells(i, "G").Value = "Bronze" Then
Me.TextBox10 = wss.Cells(i, "H").Value
End If
If wss.Cells(i, "C").Value = (Me.ComboBox2) And wss.Cells(i, "F").Value = (Me.ComboBox7) And wss.Cells(i, "G").Value = "Silver" Or _
wss.Cells(i, "C").Value = Val(Me.ComboBox2) And wss.Cells(i, "F").Value = Val(Me.ComboBox7) And wss.Cells(i, "G").Value = "Silver" Then
Me.TextBox12 = wss.Cells(i, "H").Value
End If
If wss.Cells(i, "C").Value = (Me.ComboBox2) And wss.Cells(i, "F").Value = (Me.ComboBox7) And wss.Cells(i, "G").Value = "Gold" Or _
wss.Cells(i, "C").Value = Val(Me.ComboBox2) And wss.Cells(i, "F").Value = Val(Me.ComboBox7) And wss.Cells(i, "G").Value = "Gold" Then
Me.TextBox11 = wss.Cells(i, "H").Value
End If
Next d