Private Sub UserForm_Initialize()
Label5.Caption = [j1]
End Su
'*******************
Private Sub TextBox1_Change()
Dim n As Range, J As Long, f As Long
Set WS = Worksheets("Sheet1")
Cnt = Me.TextBox1.Value: WS.[W1] = Cnt
f = WS.Cells(WS.Rows.Count, 2).End(xlUp).Row
If Cnt <> "" Then
With WS
Set n = .Range("A2:A" & f).Find(What:=Cnt, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False)
If Not n Is Nothing Then
J = n.Row
Me.TextBox2 = .Range("B" & J)
Me.TextBox3 = Evaluate("=SUMPRODUCT((D2:D10000) * (A2:A10000=W1) * (C2:C10000<>j1))")
End If
End With
Else
Me.TextBox3 = "": Me.TextBox2 = ""
End If
End Sub
'OR=============================================================
Public Property Get WS() As Worksheet: Set WS = Worksheets("Sheet1")
End Property
Private Sub UserForm_Initialize()
Set J = CreateObject("Scripting.Dictionary")
a = WS.Range("A2:A" & WS.[A65000].End(xlUp).Row)
For i = LBound(a) To UBound(a)
If a(i, 1) <> "" Then J(a(i, 1)) = ""
Next i
n = J.keys
Me.ComboBox1.List = n
Label5.Caption = [j1]
End Sub
Private Sub ComboBox1_Change()
Dim n As Range, J As Long, f As Long
Cnt = Me.ComboBox1.Value: WS.[W1] = Cnt
'''Code.....
Else
Me.TextBox3 = "": Me.TextBox2 = ""
End If
End Sub
Sumif v2.xlsm