PDA

View Full Version : [SOLVED:] Need Help in contructing a Macro the returns frequ. of searched data in chart,please!



estatefinds
07-19-2016, 12:39 PM
I have data in column AF that looks like for example 1-10-.

In column AI2:AP70.

I need a macro in which I press ALT F8 and it starts a search for how many times each piece of data occurs in column AF, for example: the first position 1-10- occurs 3 times and the macro places the 3 in the position 1-10- in the chart. so the 1-10- gets replaced with a 3 within the chart.

also I will adding data in column AF so the Macro needs to be AS LONG.

Im attaching file for example.

Thank you very much in advance!!!

estatefinds
07-19-2016, 06:51 PM
I corrected example.

snb
07-20-2016, 12:30 AM
An xlsx file can't contain a macro.
We can't help you in the construction of a macro if you don't show it to us.

BTW asking for a solution is quite another thing than asking for help to create your own solution.
You didn't manage to omit exclamation marks in the threadtitle.

p45cal
07-20-2016, 02:55 AM
in your file:

Sub blah()
Set Destn = Range("AI2:AP71")
DVal = Destn.Value
Range("AF1").Value = "temp"
Set SceData = Range(Range("AF1"), Range("AF1").End(xlDown))
SceData.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("AE1"), Unique:=True
Set Uniques = Range(Range("AE2"), Range("AE1").End(xlDown))
For Each cll In Uniques.Cells
x = Application.CountIf(SceData, cll.Value)
coords = Split(cll.Value, "-")
DVal(CLng(coords(1)), CLng(coords(0))) = x
Next cll
Range("AE1:AF1").ClearContents
Uniques.ClearContents
Destn.Value = DVal
End Sub


ps. I concur fully with what snb said.

p45cal
07-20-2016, 03:23 AM
or shorter:
Sub blah2()
With Range("AI2:AP71")
.NumberFormat = ""
.FormulaR1C1 = "=IF(COUNTIF(R2C32:R" & Range("AF2").End(xlDown).Row & "C32,R1C & ""-"" & RC43 & ""-"")>0,COUNTIF(R2C32:R" & Range("AF2").End(xlDown).Row & "C32,R1C & ""-"" & RC43 & ""-""),R1C & ""-"" & RC43 & ""-"")"
.Value = .Value
End With
End Sub

estatefinds
07-20-2016, 03:32 AM
I didn't present code cause it did something different and didn't want to confuse what i needed it to do with existing code.
I attached another example with the code I would have put there for restructuring. I apoligize:(

Thanks again!

estatefinds
07-20-2016, 03:38 AM
I had just gotten to my computer this am. Thank you Very much! you did a great Job on this Code it did Exactly what I need it to!
Great work!!!
And Again I appologize for not placing code on original request.
Sincerely.

estatefinds
07-20-2016, 03:39 AM
Thanks Again!!!:)

snb
07-20-2016, 05:12 AM
Sub M_snb()
[B14:D466] = [choose(column(B1:D1),"",countif($AF$1:$AF$500,A$14:A$466),C$14:C$466,countif($AF$1:$AF$500,C$14:C$ 466))]
End Sub