+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    07-09-2008
    Location
    Canada
    Posts
    49

    select column A and B but not row 1

    sorry for this stupid question...

    i am trying to select column A and column B and apply a filter. however, I don't want the filter to be applied to row 1...

    so i tried adding
    Code:
    Selection.Offset(1, 0)
    somewhere in the following code but i couldn't get it to work...

    Code:
    Sub Macro8()
    '
    ' Macro8 Macro
    '
    
    '
        Columns("A:B").Select
        ActiveWorkbook.Worksheets("sort").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("sort").Sort.SortFields.Add Key:=Range("A1:A351"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("sort").Sort
            .SetRange Range("A1:B351")
            .Header = xlGuess
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    End Sub
    please share your insights
    Last edited by hluk; 07-03-2009 at 12:02 AM.

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,222

    Re: select column A and B but not row 1

    I don't see any filter code, I see sort code. Forget the macro for a moment and just tell us what you want to do... Sort columns A and B by column A values and leave the header at the top?

    Something like this then?
    Code:
    Sub Sort()
    Dim LR As Long
    
    Worksheets("sort").Activate
    LR = Range("A" & Rows.Count).End(xlUp).Row
    
    Range("A2:B" & LR).Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlNo
    
    End Sub
    Last edited by JBeaucaire; 07-02-2009 at 11:54 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-09-2008
    Location
    Canada
    Posts
    49

    Re: select column A and B but not row 1

    exactly. thank you

Thread Information

Users Browsing this Thread

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

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.2.0