PDA

View Full Version : [SOLVED:] Need help constructing a vba code to show frequency of given values within delim data



estatefinds
09-21-2016, 06:48 PM
Hi, I have a constant data in column A2 to A36; this data is values 1 to 35.

In column A38 to A114 is the deliminated data making a combination of numbers using 1 to 35; the same numbers that are listed in incolumn A2 to A36.

In column B2 to column B36 is the count of the numbers that are found in column A38 to A114.

My ultimate goal is to have a macro in which I select the data in column A38 to how ever many rows down, press Alt F8 and it returns the count of the of the numbers that are found within the data in column A38 to for this example to A114 and place the count in the column B to right of the number in column A2 to A36.

I had placed the count for each number in column B. for example the number 1 occurs in the data in column A38 to A114 59 times. the number 2, 46 times the number 3, 43 times and so on.

Thank you very much in advance!

Sincerely Dennis

mana
09-21-2016, 07:09 PM
Option Explicit

Sub test()
Dim dic As Object
Dim c As Range
Dim s, e

Set dic = CreateObject("scripting.dictionary")

For Each c In Range("a38:a114")
s = Split(c.Value, "-")
For Each e In s
dic(Val(e)) = dic(Val(e)) + 1
Next
Next

For Each c In Range("a1:a38")
c.Offset(, 1).Value = dic(c.Value)
Next

End Sub

estatefinds
09-21-2016, 07:13 PM
It worked great!!! Thank you Ill test it on the bigger data.
Thanks again:)