PDA

View Full Version : Solved: Userform Event (SOLVED)



Nicolaf
08-25-2011, 08:22 AM
Hi,

I have following data in Sheet2 in A2:C11

France Apples 2
Italy Apples 5
France Berries 4
Spain Cherries 1
Guatemala Bananas 6
Italy Pears 4
France Grapes 7
Italy Grapes 8
France Pears 8
Spain Apples 3

I would like to create a Useform in Sheet2 which has textbox for fruit which counts all the fruit chosen and puts number in cell A1 Sheet1 when the Count command button is pressed in Userform.
So if I put Apples in textbox then click OK I should get number 10 in Sheet1 cell A1. How do I do that?

Thanks,
Nix :think:

Bob Phillips
08-25-2011, 08:40 AM
Private Sub TextBox1_AfterUpdate()
With Worksheets("Sheet2")

Worksheets("Sheet1").Range("A1").Value = Application.SumIf(.Columns(2), Me.TextBox1.Text, .Columns(3))
End With
End Sub

Nicolaf
08-25-2011, 09:13 AM
Great thanks!
Nix

:hi: