0

New to excel vba, Sorry if this is too obvious...
I got this data in spreadsheet,
How can filter out the table by "title" column
So I will be able to select part of the table by filtered by title
thanks

book name       Description                             title
gsod        Samples from US weather since 1929          title1
mlab        Measurement data of performance             title1
natality    Birth States from 1969 to 2008              title2
shakespeare Word index for works of                     title2
wikipedia   Revision information for Wikipedia          title1
2
  • 1
    what version of Excel are you using? In Excel2007 and 2010 you can just select the data and 'Format as a Table', after that the headers get a triangle next to them which you can click to filter Commented Oct 15, 2013 at 14:51
  • Its 2010, trying to do this programatically ... Thanks Commented Oct 15, 2013 at 14:58

1 Answer 1

2

A simple example to accomplish what you are trying to do is:

Sub SortColumnC()

If Sheets(1).AutoFilterMode = False Then
    Sheets(1).Range("A1:C1").AutoFilter
End If

RowCount = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
ActiveWorkbook.Worksheets(1).AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets(1).AutoFilter.Sort.SortFields.Add Key:=Range("C2:C" & RowCount), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(1).AutoFilter.Sort
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
End With

End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

I Have found a working solution: stackoverflow.com/questions/10849177/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.