Counting quantity - data contained in one cell by new line

kev2131

New Member
Joined
Aug 8, 2021
Messages
3
Office Version
  1. 2007
Platform
  1. Windows
Hello,



Thank you in advance to answer my question!



I'm a beginner in VBA and i'm working on some code that can help me out to count the total number of specific product from the cell, for example in column B it contained different shoes brand with quantity we sold, i want to know the total number of adidas we sold on the entire column B, so I select the option box says adidas then click on count button, it will then give me the result of 6 next to Label1, below is my code but seems not work.



Please note that the data that i received is system generated and data are contained in one cell by new line, so that is complicated for me.

Please also see attachment of how my userform look like.



Private Sub Count_Click()



Dim result As Double

'Assign the variable

result = Application.WorksheetFunction.CountIf(Range("B2:B50"), "adidas")

'Show the result

Label1.Caption = "result"



End Sub



Thanks and appreciate that!
 

Attachments

  • Capture.JPG
    Capture.JPG
    75.9 KB · Views: 11

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Counting quantity - data contained in one cell by new line - OzGrid Free Excel/VBA Help Forum
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Counting quantity - data contained in one cell by new line - OzGrid Free Excel/VBA Help Forum
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
Thank you and sorry for that!
 
Upvote 0
Due to cross posting, could you please remove this thread, thank you!
 
Upvote 0
There is no need to have the thread removed.
 
Upvote 0

Forum statistics

Threads
1,214,617
Messages
6,120,541
Members
448,970
Latest member
kennimack

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