Hi and Welcome to the MrExcel forum. Please accept my warmest greetings and sincere hope that all is well.
I recommend using combobox for the name of the product and for the process number.
View attachment 95959
Put all the code in the form.
VBA Code:
Option Explicit
Private Sub ComboBox1_Change()
Dim c As Range
Dim dic As Object
Set dic = CreateObject("Scripting.Dictionary")
ComboBox2.Clear
ComboBox2.Value = ""
TextBox1.Value = ""
TextBox2.Value = ""
For Each c In Sheets("Sheet1").Range("A2", Sheets("Sheet1").Range("A" & Rows.Count).End(3))
If c.Value = ComboBox1.Value Then
dic(c.Offset(, 1).Value) = Empty
End If
Next
ComboBox2.List = dic.keys
End Sub
Sub totals()
Dim c As Range
Dim totH As Double, totQ As Double
Dim cmb2 As Variant
If ComboBox1.ListIndex = -1 Then Exit Sub
With ComboBox2
If .ListIndex = -1 Then Exit Sub
If IsNumeric(.Value) Then
cmb2 = Val(.Value)
Else
cmb2 = .Value
End If
End With
For Each c In Sheets("Sheet1").Range("A2", Sheets("Sheet1").Range("A" & Rows.Count).End(3))
If c.Value = ComboBox1.Value And c.Offset(, 1).Value = cmb2 Then
totH = totH + c.Offset(, 2).Value
totQ = totQ + c.Offset(, 3).Value
End If
Next
TextBox1.Value = totH
TextBox2.Value = totQ
End Sub
Private Sub ComboBox2_Change()
Call totals
End Sub
Private Sub UserForm_Activate()
Dim dic As Object
Dim c As Range
Set dic = CreateObject("Scripting.Dictionary")
For Each c In Sheets("Sheet1").Range("A2", Sheets("Sheet1").Range("A" & Rows.Count).End(3))
dic(c.Value) = Empty
Next
ComboBox1.List = dic.keys
End Sub
I attach my file with the form and the code for you to try.
Select the product, then the number and the totals are calculated automatically.
drive.google.com
--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------