VBA code to loop count data in one cell and compare that count to another cell value

philwojo

Well-known Member
Joined
May 10, 2013
Messages
533
Hello, I am still struggling with my VBA skills and trying to figure out how to do this. I can picture in my head what I need to do, but nothing is working for me with VBA.

Here is my raw data, or a sample of data:

Code:
1000,1.0,RLZSUA1,02022018092900,2100,1.0,SPIF41,PG001,40.00,USD,01262018,02262108,950,0.00,0.00,,,,,YES,,,,,8000575,1,1,,,,,,,,,,,,,,,,
3000,1.0,SPIF41,1,45645a,10302017,,5.00,,5.00,testing comments,,,,
3000,1.0,SPIF41,2,45645b,10302017,,5.00,,5.00,testing comments,,,,
3000,1.0,SPIF41,3,45645c,10302017,,5.00,,5.00,testing comments,,,,
3000,1.0,SPIF41,4,45645d,10302017,,5.00,,5.00,testing comments,,,,
3000,1.0,SPIF41,5,45645e,10302017,,5.00,,5.00,testing comments,,,,
3000,1.0,SPIF41,6,45645f,10302017,,5.00,,5.00,testing comments,,,,
3000,1.0,SPIF41,7,45645g,10302017,,5.00,,5.00,testing comments,,,,
3000,1.0,SPIF41,8,45645h,10302017,,5.00,,5.00,testing comments,,,,
2100,1.0,SPIF42,PG001,555.00,USD,01262018,02262108,950,,,,,,,YES,Notes,,,,8000720,1,1,,,,,,,,,,,,,,,,
3000,1.0,SPIF42,1,163,11012017,,500.00,,500.00,,,,,
3000,1.0,SPIF42,2,936,11052017,,5.00,,5.00,,,,,
2100,1.0,SPIF43,PG001,250.00,USD,01262018,02262108,950,,,,,250.00,250.00,YES,Notes,,,,8000720,1,1,,,,,,,,,,,,,,,,
3000,1.0,SPIF43,1,741,11052017,,250.00,,250.00,,,,,
2100,1.0,SPIF50,PG001,95.00,USD,,02262018,950,,,,,,,YES,,,,,,,,,,Elmer Fudd Rabbit Farm,Elmer.Fudd@xyz.com,,,,,,,,,,,,
3000,1.0,SPIF50,63,11012017,,100.00,,100.00,,,,,
3000,1.0,SPIF50,2,13,11012017,,-5.00,,-5.00,,,,,
5000,4,,

I am currently using VBA to take that and break it out in to columns, all that is good.

What I want to do now is compare how many times the value of "2100" is in what will be my column-B and then compare that to the one line of data that starts with "5000" and has a value in Column-C.

In the above example There are four (4) instances of "2100" and as you can see for the line with "5000" in it shows a "4" for what will be column-C so that would be good. I want to flag that value in the "5000" line if it doesn't match the total number of "2100" values in the data set. So if it was a 3 in this example I would want to turn the cell Red and make the Text bold.

Thanks for any help.

Phil
 
Last edited by a moderator:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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