vba that will filter then select all items excluding the header

Can an expert help me out with this as I cannot find the answer anywhere.

Using VBA I need to filter [lets say on column H] the word 'Move' then select all of the items except for the header row.

Thanks
JagwarmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roy CoxGroup Finance ManagerCommented:
Try this, it assumes data starts in A1

Option Explicit

Sub SelectFilteredData()
    Dim rRng    As Range
    Dim lCalc  As Long
    
    With Application
        lCalc = .Calculation
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
 On Error GoTo exit_proc
  
     
     'Sheet with the data, change the name
    With Sheet1
        .AutoFilterMode = False
         
         'Apply the filter, this range of data starts in A1
        .Cells(1, 1).CurrentRegion.AutoFilter Field:=8, Criteria1:="Move"
         
        With .AutoFilter.Range
            On Error Resume Next
            Set rRng = .Resize(.Rows.Count - 1, 1) _
            .SpecialCells(xlCellTypeVisible)
'            On Error GoTo 0
            If Not rRng Is Nothing Then rRng.EntireRow.Select
        End With
         'Remove the AutoFilter
        .AutoFilterMode = False
    End With
     
exit_proc:
        .ScreenUpdating = True
        .Calculation = lCalc
    End With
     
End Sub

Open in new window

0
JagwarmanAuthor Commented:
Roy that selects the header row [row 1] as well. I want to exclude row 1.

thanks
0
ProfessorJimJamCommented:
Jagwarman,


use this code. it will exclude the header

Option Explicit

Sub SelectFilteredData()
    Dim rRng    As Range
    Dim lCalc  As Long
    
    With Application
        lCalc = .Calculation
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
 On Error GoTo exit_proc
  
     
     'Sheet with the data, change the name
    With Sheet1
        .AutoFilterMode = False
         
         'Apply the filter, this range of data starts in A1
        .Cells(1, 1).CurrentRegion.AutoFilter Field:=8, Criteria1:="Move"
         
        With .AutoFilter.Range
            On Error Resume Next
            Set rRng = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
'            On Error GoTo 0
            If Not rRng Is Nothing Then rRng.EntireRow.Select
        End With
         'Remove the AutoFilter
        .AutoFilterMode = False
    End With
     
exit_proc:
        .ScreenUpdating = True
        .Calculation = lCalc
    End With
     
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JagwarmanAuthor Commented:
that works for me, exactly what I need. This is where I hate the points allocation on ee because Roy's code was correct apart from row 23. so I will split points and hope you are ok with that
0
Roy CoxGroup Finance ManagerCommented:
Sorry, I was just leaving for work and misread the post

Option Explicit



Sub SelectFilteredData()
    Dim rRng    As Range
    Dim lCalc  As Long
    
    With Application
        lCalc = .Calculation
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
 On Error GoTo exit_proc
  
     
     'Sheet with the data, change the name
    With Sheet1
        .AutoFilterMode = False
         
         'Apply the filter, this range of data starts in A1
        .Cells(1, 1).CurrentRegion.AutoFilter Field:=8, Criteria1:="Move"
         
        With .AutoFilter.Range
            On Error Resume Next
            Set rRng = .Offset(1).Resize(.Rows.Count - 1, .Columns.Count) _
            .SpecialCells(xlCellTypeVisible)
     On Error GoTo 0
            If Not rRng Is Nothing Then rRng.Select
        End With
         'Remove the AutoFilter
'       .AutoFilterMode = False
    End With
     
exit_proc:
        .ScreenUpdating = True
        .Calculation = lCalc
    End With
     
End Sub

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.