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 addingsomewhere in the following code but i couldn't get it to work...Code:Selection.Offset(1, 0)
please share your insightsCode: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
Last edited by hluk; 07-03-2009 at 12:02 AM.
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 theicon 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!)
exactly. thank you
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks