Hello world,
I am quite new to vba and I am trying to build a 3 step macro that will
1- separate values ("deconcatenate them") from a given column in a different location on the same sheet
2-Filter these values so that I get a list of unique values
3-Count the occurences of each unique value
The macro is quite simple, i actually did not write it myself except for step 2. And the glitch is in... step 2.
Sub PieChartCommodityInvolved()
'
'PieChartCommodityInvolved Macro
'1-Converts each value from column P in a distinct column (Z and next columns)
'2-Filtrates the (Z,...) range so that each type of commodity appears once in column AI
'3- Computes the number of occurences of each commodity in AJ
Dim i As Long
'1
Sheets("Data input").Select
Range("P3:P300").Select
Selection.TextToColumns Destination:=Range("Z3"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=True, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
'2
Range("Z3").Select
For i = 0 To 65536
i = i + 1
Range(Selection, Range("Z2").Offset(0, i).EndToRight).Select
Next i
Selection.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("AI"), Unique:=True
'3
Range("AJ4").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(R[-1]C[-9]:R[296]C[-2],RC[-1])"
Range("AJ4").Select
Selection.AutoFill Destination:=Range("AJ4:AJ300"), Type:=xlFillDefault
Range("AJ4:AJ300").Select
End Sub
At line
Range(Selection, Range("Z2").Offset(0, i).EndToRight).Select
i am returned the error "438, method does not support this object"
The thing is that i am trying to select only the non-void cells to filter them.
Big love for your help !!
Bookmarks