How to Match a string in column A and sum the values in column B that matched

plcoomer

New Member
Joined
Jul 5, 2017
Messages
4
Hello,
thanks in advance for your help.

I'm trying to search for a String (lets say "2258" which lives in userform1.Textbox1.text ) in worksheet in range "A2:A800" and then sum all the values in range "B2:B800" which matched.

I can find one easy enough but when there are multiplu 2258's I don't know how to step through the data and collect them all.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Put the following in a commandbutton:

VBA Code:
Private Sub CommandButton1_Click()
  Dim xd
  xd = WorksheetFunction.SumIf(Range("A2:A800"), TextBox1.Value, Range("B2:B800"))
  MsgBox xd
End Sub

--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------
 
Upvote 0

Forum statistics

Threads
1,215,450
Messages
6,124,912
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top