Filter excel and color rang

Hi My Requirement is
filter an excel sheet and colour the filtered results alone. thats all . i dont want to extract the Filtered results as data table etc.,
i went through forums and filter table activity inside excel activities also. what they mean by table in filter table activity ?
all i have is an excel sheet. which generated dynamically , where will i search for a table there ?

I can use set range color or via a VB script but all those are slow. say for 5000 rows it takes more than 30-40 minutes.
the point here is the 5000 does not fall under one range. A5:V25 -> 20 rows then A73-V115-42 rows likethat. some times a range is a simple one or two rows. so above methods are in efficient

i want to apply a method which is as simple and fast as clicking image and fill colour thats all!

@Seetharaman_K – What is your Filter condition? Your requirement is still not clear at all…

my filter condition is based on couple of values of 2 columns. say if column1 = “A” or “B” then i wantto colour those rows.

@Seetharaman_K - Please chk here
Color Excel


You could use VB.NET here within an invoke code activity, it should be much more faster. See attached file.

FilterRows.txt (1.3 KB)

i did use a script. it just took half the time of the colour range activity. not much of an improvement i will say. but found a way.
create a table using create table activity (basically make the entire excel as a table)
filter the table using filter table activity
then colour entire excel , (now it will colour only the filtered result)
now am looking a way to take out the filter or delete the filter. so that when user opens the file back they wont see the filter.

In the VB script, did you specify


when filtering?

This will activate only the visible cells. If you do not do this you will still have the hidden cells, slowing down the running time.

If it takes 30-40 minutes to set a color of only 5000 rows, there is probably some bug in the VBnet code. If implemented correctly, it should be quick.

I had a similar problem. I filtered a big table, and looped through the AutoFilter results like this:

For Each r In .Range(…).Rows.SpecialCells(xlCellTypeVisible)

Here, .Range(…) is just symbolizing the range I was left with after filtering.

When I set SpecialCells(xlCellTypeVisible) I experienced a significant improvement in running time.

i did the auto filter results do u know how do i color the result. there is a range also in my case . ie , i need not colour all columns i will have to omit last 8 columns . any idea how to get that ? i tried this xlCellTypeVisible but my code is saying its not declared and according to documentation xlCellTypeVisible is type under excel application. but when i try to declare its not working.

xlApp = New Microsoft.Office.Interop.Excel.Application
xlWorkBook = xlApp.Workbooks.Open(FilePath)
xlApp.DisplayAlerts = False
xlWorkSheet = CType(xlWorkBook.Worksheets.Item(“Sheet1”), Microsoft.Office.Interop.Excel.Worksheet)
xlworksheet.UsedRange.AutoFilter(1, “818714”)
Dim TFiltro As Range
TFiltro = xlWorkSheet.UsedRange.SpecialCells(xlApp.)
TFiltro.Interior.ColorIndex = 10