View Single Post
 
Old 03-24-2023, 06:05 AM
bah73 bah73 is offline Windows 11 Office 2021
Novice
 
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