If you can add an extra column to the file, even at runtime, then you can try this approach:
Use For Each Excel Row to loop through the rows of your file
(For each row) Use “Get Cell Color” for the Cell in the column you want to filter.
Check if the retrieved color matches the light green. If so, update the new column with a fixed value (i.e., TRUE, or “1”, or whatever you want)
When you’re done with the filter, use the “Filter” activity on the new column you’ve added (which will only contain values for the rows where the cells have the desired color
You can try saving a vba as text file and use invoke vba activity
Sub Macro1(ColumnIndex As Integer)
ActiveSheet.UsedRange.AutoFilter Field:=ColumnIndex, Criteria1:=RGB(255, 255, 0), Operator:=xlFilterCellColor
End Sub
change r g b values as per the color you need…ColumnIndex is the Count of the column
Option Explicit
Sub FilterColumnByColor(SheetName As String,SheetRange As String)
Dim ws As Worksheet
Dim rng As Range
Dim filterRange As Range
Dim cell As Range
Dim filterColor As Long
' Set the worksheet
Set ws = ThisWorkbook.Sheets(SheetName) ' Replace "Sheet1" with your sheet name
' Set the range of the column you want to filter
Set rng = ws.Range(SheetRange) ' Replace "A1:A10" with your column range
' Set the color to filter (Light Green RGB value)
filterColor = RGB(144, 238, 144)
' Clear previous filters (if any)
ws.AutoFilterMode = False
' Filter the column based on color
rng.AutoFilter Field:=1, Criteria1:=xlFilterCellColor, Operator:=xlFilterFontColor, RGB(filterColor)
' Get the filtered range
On Error Resume Next
Set filterRange = rng.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End Sub
You can modify some things here and then save in the notepad as “FilterColumnByColor.vb”
Use a Excel Application Scope give the file path
Invoke VBA and pass the file path and give the Method name as “FilterColumnByColor”
Give the input parameter {“Sheet2”,“A1:N10”}
The “Format Cell” activity will change the color of the cell in Excel but it will not provide the result you’re looking for, because it doesn’t filter anything.
I need to replace this with my sheet name right? And how to pass column index? My column index is 17. Please see below image and let me know if it is right?
I have modified your code in below way please check.
Sub Macro1(ColumnIndex As Integer)
Data.UsedRange.AutoFilter Field:=ColumnIndex, Criteria1:=RGB(144, 238, 144), Operator:=xlFilterCellColor
End Sub