Results 1 to 7 of 7

Range selection

Threaded View

  1. #1
    Registered User
    Join Date
    07-30-2013
    Location
    new york
    MS-Off Ver
    Excel 2010
    Posts
    4

    Wink Range selection

    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 !!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Range(Selection, Selection.End(xlDown)).Select goes to 65536 instead of last filled row
    By looney in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-12-2013, 10:51 AM
  2. Replies: 2
    Last Post: 04-20-2012, 12:23 PM
  3. Hide rows in range 2 based on filter selection in range 1
    By gtol in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-28-2012, 02:09 PM
  4. Selecting range using .range. But can you do same selection using .columns
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-01-2011, 01:31 PM
  5. Range selection based on adjacent cell range
    By iguss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-20-2008, 07:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1