Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2018, 12:20 AM
kannan14 kannan14 is offline Automating Advanced filtering Windows 8 Automating Advanced filtering Office 2013
Novice
Automating Advanced filtering
 
Join Date: Jul 2018
Posts: 1
kannan14 is on a distinguished road
Default Automating Advanced filtering

Hi everyone.
I am trying to automate Advanced filtering option. The first few lines gives the criteria and the below table is actual data.

The number of rows in filtering can change dynamically based on the inputs given (it can be a single line or two or three lines).

Advanced filtering option requires no blank row. So the criteria table size should get adjusted based on the number of rows of criteria. I am a new to macro programming. Could you please check and let me know where I am making mistake in the code.
Thanks and appreciate your help.
Attached Files
File Type: xlsm check.xlsm (15.7 KB, 12 views)
Reply With Quote
  #2  
Old 07-19-2018, 06:19 AM
p45cal's Avatar
p45cal p45cal is offline Automating Advanced filtering Windows 10 Automating Advanced filtering Office 2016
Expert
 
Join Date: Apr 2014
Posts: 869
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

Since you have the criteria range in its own 'white space'', you can use CurrentRegion to determine its extent, so you only need one line (you don't need the Dims because the code is inside the sheet's own code-module so all unqualified ranges refer definitively to that same sheet):
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("B12:C24").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("B3").CurrentRegion, Unique:=False
End Sub
Reply With Quote
  #3  
Old 07-27-2018, 04:19 AM
p45cal's Avatar
p45cal p45cal is offline Automating Advanced filtering Windows 10 Automating Advanced filtering Office 2016
Expert
 
Join Date: Apr 2014
Posts: 869
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

Delete one:
  • Thanks p45cal, that worked a treat.
  • That didn't work; what rubbish.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating Updates For Advanced Filtering Into New Sheet indieben Excel 12 07-23-2018 04:08 PM
Automating Advanced filtering Need to put citations in, need help automating if possible AOEUD Word 2 11-06-2015 02:58 PM
Automating Advanced filtering Filtering (advanced?) in Pivot Table canajun Excel 6 01-17-2015 05:01 AM
Automating Advanced filtering automating powerpoint trstbmbk PowerPoint 1 11-12-2013 02:09 AM
Automating Advanced filtering Automating dates OCM Outlook 4 04-03-2013 08:29 PM

Other Forums: Access Forums

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


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft