Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 07-02-2009, 10:52 PM
hluk hluk is offline
Registered User
 
Join Date: 09 Jul 2008
Location: Canada
Posts: 45
hluk is becoming part of the community
select column A and B but not row 1

Please Register to Remove these Ads

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.
Reply With Quote
  #2  
Old 07-02-2009, 11:49 PM
JBeaucaire's Avatar
JBeaucaire JBeaucaire is offline
Forum Guru
 
Join Date: 21 Mar 2008
Location: Bakersfield, CA
MS Office Version:2003 (can read 2007 files)
Posts: 9,439
JBeaucaire makes giving solutions look like childsplay JBeaucaire makes giving solutions look like childsplay JBeaucaire makes giving solutions look like childsplay JBeaucaire makes giving solutions look like childsplay JBeaucaire makes giving solutions look like childsplay JBeaucaire makes giving solutions look like childsplay JBeaucaire makes giving solutions look like childsplay JBeaucaire makes giving solutions look like childsplay JBeaucaire makes giving solutions look like childsplay JBeaucaire makes giving solutions look like childsplay
Send a message via Skype™ to JBeaucaire
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
__________________
If you've been given good help, use the icon in that post to give reputation feedback, it is appreciated.
Always put your code between [code] and [/code] tags.
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)

Last edited by JBeaucaire; 07-02-2009 at 11:54 PM.
Reply With Quote
  #3  
Old 07-03-2009, 12:02 AM
hluk hluk is offline
Registered User
 
Join Date: 09 Jul 2008
Location: Canada
Posts: 45
hluk is becoming part of the community
Re: select column A and B but not row 1

exactly. thank you
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump