Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Excel > Excel Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 11-07-2018, 12:52 PM
trevorc trevorc is offline Windows 7 32bit Office 2013
Advanced Beginner
 
Join Date: Jan 2017
Posts: 93
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default filter using a table list with VBA

Hi All,


I am trying to improve on some code I have, currently the code below works fine, but if I need to add a condition to the list for the filter I also have to add it to this code. Is it possible to use a table list for the filter?
It also seems to have a problem with Capital letters - with/without requires 2 entries, can I also fix this other than with a list from a table?

Code:
Sub Filter_Closed()
t = ActiveSheet.Shapes("fltr").TextFrame.Characters.Text
     If ActiveSheet.Shapes("fltr").TextFrame.Characters.Text = "Filter Closed" Then
        ActiveSheet.ListObjects("Customers").Range.AutoFilter Field:=3, _
        Criteria1:=Array("Done, waiting for confirmation of payment", _
        "In Transit", "Received for Repair, Proceed with Repair", _
        "waiting delivery of parts", "Waiting for Email Address", "Waiting for reply from customer", "="), Operator _
        :=xlFilterValues
        ActiveSheet.Shapes("fltr").TextFrame.Characters.Text = "Show All"
      Exit Sub
      Else
        ActiveSheet.ListObjects("Customers").Range.AutoFilter Field:=3
        ActiveSheet.Shapes("fltr").TextFrame.Characters.Text = "Filter Closed"
      End If
End Sub
Reply With Quote
  #2  
Old 11-10-2018, 09:11 AM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 640
NoSparks will become famous soon enoughNoSparks will become famous soon enough
Default

If not yet resolved...
have you tried using advanced filter and Option Compare Text ?
Reply With Quote
  #3  
Old 11-11-2018, 12:47 PM
trevorc trevorc is offline Windows 7 32bit Office 2013
Advanced Beginner
 
Join Date: Jan 2017
Posts: 93
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

Thanks,
I did try that but it failed to work correctly, even on a simple subset of data, I couldn't even tweak the VBA code to make it work after using the recorder to create the code, the recorded code didn't even work. I'll look at it again at a later date
Reply With Quote
  #4  
Old 11-11-2018, 04:48 PM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 640
NoSparks will become famous soon enoughNoSparks will become famous soon enough
Default

Like this ?
Attached Files
File Type: xlsm TrevorC_Filter.xlsm (18.5 KB, 3 views)
Reply With Quote
  #5  
Old 11-11-2018, 04:57 PM
trevorc trevorc is offline Windows 7 32bit Office 2013
Advanced Beginner
 
Join Date: Jan 2017
Posts: 93
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

Hi Thanks for that,
I can see how it works, I just need to transfer it into my workbook.
regards
Trevor
Reply With Quote
  #6  
Old 11-12-2018, 12:41 PM
trevorc trevorc is offline Windows 7 32bit Office 2013
Advanced Beginner
 
Join Date: Jan 2017
Posts: 93
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

I found out why mine wasn't working, My headers didn't match and it filtered out everything. All good now.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop down list/ filter help with sharepoint DB12345 Misc 0 10-25-2016 02:03 PM
Filter Mail Merge based on a list of filter criteria AusSteelMan Mail Merge 2 05-09-2016 03:35 PM
Data validation list filter with range defined by OFFSET Mango123 Excel 4 03-18-2014 02:52 PM
filter according to a list of filters userman Excel 2 06-12-2012 02:19 AM
Growing Filter List rbdmg Mail Merge 1 10-10-2011 02:56 AM


All times are GMT -7. The time now is 05:05 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft