coloring the filtered results

karges

New Member
Joined
Dec 28, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
i have a very huge excel sheet which has 200000 rows. and i need to do a filter based on values of certain columns and the most important task is to color the filtered results. i have the following vb code
VBA Code:
xlApp = New Microsoft.Office.Interop.Excel.Application
Dim xRange As Microsoft.Office.Interop.Excel.Range
Dim xlviscels As microsoft.Office.Interop.Excel.XlCellType
xlviscels = New microsoft.Office.Interop.Excel.XlCellType
xlWorkBook = xlApp.Workbooks.Open(FilePath)
xlApp.DisplayAlerts = False
xlWorkBook.Activate()
xlWorkSheet = CType(xlWorkBook.Worksheets.Item("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
xlworksheet.UsedRange.AutoFilter(1,"818714")
xlWorkBook.Save()
xlWorkBook.Close(true)
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkBook)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkSheet)
GC.Collect()
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
VBA Code:
Sub ColorAutoFilter()    Dim FilterNum As Long    With ActiveSheet        If .AutoFilterMode Then            For FilterNum = 1 To .AutoFilter.Filters.Count                If .AutoFilter.Filters(FilterNum).On Then                    .AutoFilter.Range.Cells(1, FilterNum).Interior.ColorIndex = 6 'yellow                Else                    .AutoFilter.Range.Cells(1, FilterNum).Interior.ColorIndex = xlNone                End If            Next        Else            .Cells.Interior.ColorIndex = xlNone        End If    End With End Sub

above is the code to colour the filter data. i want the entire code as a VBA file . for some reason VB.net is not working
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top