Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-24-2023, 06:05 AM
bah73 bah73 is offline MS Project VBA Help Filtering Windows 11 MS Project VBA Help Filtering Office 2021
Novice
MS Project VBA Help Filtering
 
Join Date: Mar 2023
Posts: 1
bah73 is on a distinguished road
Default MS Project VBA Help Filtering

Hi,



I am applying a column filter then adding a value to an adjacent column.

I problem I am having is when the filter returns no value the code still adds a value to the adjacent column.

This creates a new task line.

The code I need help with is if the filter returns no values to skip to next filter in the code.

I have added some code below.

Code:
'''''Examples of a filter returning no value and adding format and text to adjacent column creating a new task
'''''When filter returns no value I need to skip to next set of code

'''''Skip to next if no value returned from filter 
    SetAutoFilter FieldName:="Text30", FilterType:=pjAutoFilterCustom, Test1:="contains", Criteria1:="ALS"
    SetAutoFilter FieldName:="Resource Names", FilterType:=pjAutoFilterIn, Criteria1:="PC-CPINSP"
    SelectTaskColumn Column:="Text3"
    Font32Ex CellColor:=13159680
    SetTaskField Field:="Text3", Value:="CLASSIFIED"
    FillDown
    FilterClear
     

'''''Skip to next if no value returned from filter  
    SetAutoFilter FieldName:="Text30", FilterType:=pjAutoFilterCustom, Test1:="contains", Criteria1:="ALS"
    SetAutoFilter FieldName:="Resource Names", FilterType:=pjAutoFilterIn, Criteria1:="PC-CRNINSP"
    SelectTaskColumn Column:="Text3"
    Font32Ex CellColor:=13159680
    SetTaskField Field:="Text3", Value:="Crane"
    FillDown
    FilterClear
    
    
'''''Skip to next if no value returned from filter
    SetAutoFilter FieldName:="Text30", FilterType:=pjAutoFilterCustom, Test1:="contains", Criteria1:="ALS"
    SetAutoFilter FieldName:="Resource Names", FilterType:=pjAutoFilterIn, Criteria1:="PC-DRONE"
    SelectTaskColumn Column:="Text3"
    Font32Ex CellColor:=13159680
    SetTaskField Field:="Text3", Value:="Drone"
    FillDown
    FilterClear
Reply With Quote
  #2  
Old 03-30-2023, 09:10 AM
ProjectPlanner's Avatar
ProjectPlanner ProjectPlanner is offline MS Project VBA Help Filtering Windows 10 MS Project VBA Help Filtering Office 2019
Advanced Beginner
 
Join Date: Mar 2021
Location: UK
Posts: 72
ProjectPlanner is on a distinguished road
Default

This post from Stack Overflow might help you vba - How to check if a filter has any results? - Stack Overflow
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filtering Zetta Excel 0 07-29-2017 12:08 PM
Microsoft Project Server, Microsoft Project Online and Project Web App - Whats the difference? chocolateCupcakes Project 1 02-11-2017 12:25 PM
Filtering Tasks timvb85 Outlook 0 11-15-2010 08:30 PM
Filtering out CC's arzsupra Outlook 0 03-11-2008 05:55 PM
contacts filtering bubba622 Outlook 0 05-01-2006 03:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:15 PM.


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