Assigning a Value based on the Count of numbers in a specific Coumn

daltendavis

New Member
Joined
Jun 26, 2018
Messages
37
I am currently having to manually count how many times a number appears in a single column ranging from 25-50 rows long. I need a VBA code that allows me to take the numbers in the pasted column and not only count them but apply a value to them. For Example:

Pasted on sheet 1 Column A:
111
222-*333
444-555-777
333-*555

That would be an example of a shortened version of something pasted. I need it to return values like so on sheet 2:

[TABLE="class: grid, width: 50"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]111[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]222[/TD]
[TD].5[/TD]
[/TR]
[TR]
[TD]333[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]444[/TD]
[TD].33[/TD]
[/TR]
[TR]
[TD]555[/TD]
[TD].83[/TD]
[/TR]
[TR]
[TD]777[/TD]
[TD].33[/TD]
[/TR]
</tbody>[/TABLE]


Essentially if a number is by itself it represents a single truck, if there are 2 numbers in a single cell it represents 2 stores on a single truck, 3 3 stores on a single truck, using 33% of said truck.

In the set I will be pasting sometimes it reads "OFF" or a string of letters in a cell, I do not need that, also when a store on a truck is split it uses an * in front which is what is seemingly making the count so difficult. If there is any more information I can give feel free to ask. This is a daily dispatch sheet that I receive everyday. An example of an entire column I will paste is as follows:

[TABLE="width: 173"]
<colgroup><col></colgroup><tbody>[TR]
[TD]CLM CHEP[/TD]
[/TR]
[TR]
[TD]CLM CHEP[/TD]
[/TR]
[TR]
[TD]703 - 551[/TD]
[/TR]
[TR]
[TD]925 - 909[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]975 - 153[/TD]
[/TR]
[TR]
[TD]705 - 879[/TD]
[/TR]
[TR]
[TD]1 Pal WC Meats - 849 - 531[/TD]
[/TR]
[TR]
[TD]461 - 502[/TD]
[/TR]
[TR]
[TD]597 - 683[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]021 - 099[/TD]
[/TR]
[TR]
[TD]093 - 386[/TD]
[/TR]
[TR]
[TD]841 - 048[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]118 - 938[/TD]
[/TR]
[TR]
[TD]102 - 407[/TD]
[/TR]
[TR]
[TD]167 - 900[/TD]
[/TR]
[TR]
[TD]657 - 699[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]014 - 019[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]132 - 073[/TD]
[/TR]
[TR]
[TD]*022 - 136 - 164[/TD]
[/TR]
[TR]
[TD]077[/TD]
[/TR]
[TR]
[TD]508[/TD]
[/TR]
[TR]
[TD]WEST ROCK[/TD]
[/TR]
[TR]
[TD]409 - 888[/TD]
[/TR]
[TR]
[TD]719[/TD]
[/TR]
[TR]
[TD]933 - 983[/TD]
[/TR]
[TR]
[TD]395[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]015 - 790[/TD]
[/TR]
[TR]
[TD]049 - 043[/TD]
[/TR]
[TR]
[TD]829 - 022[/TD]
[/TR]
[TR]
[TD]124 - 470[/TD]
[/TR]
[TR]
[TD]850 - 788[/TD]
[/TR]
[TR]
[TD]058 - 912[/TD]
[/TR]
[TR]
[TD]OFF[/TD]
[/TR]
[TR]
[TD]941 - 940[/TD]
[/TR]
[TR]
[TD]137 - 989[/TD]
[/TR]
[TR]
[TD]CLM CHEP



[/TD]
[/TR]
</tbody>[/TABLE]

It varies on a daily basis and sometimes can get up to 70 rows, however is always in a single column. I have a clear macro button set up so the Idea is to put this macro onto a button and essentially paste, take value of what I need on a separate workbook, clear the column, and paste the next day continuing the process.

Thanks in advance
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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