Jump to content

How to fetch the entire row in excel which is highlighted


spoo
 Share

Recommended Posts

If you are looking for yellow cells then the answer is: No, the UDF does not support the needed FindFormat function.
I check if you can filter on color and then just read the filtered lines.

Another way is to use COM without the UDF as described here:
https://docs.microsoft.com/en-us/office/vba/api/excel.cellformat

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This example works for me (for red cells):

#include <Excel.au3>

; Create workbook with 3 rows and 3 columns. Set cells A1 and A3 to red
Global $aUsedRow, $sMaxUsedColumn
Global $oExcel = _Excel_Open()
Global $oWorkbook = _Excel_BookNew($oExcel)
Global $aValues = [[11, 21, 31], [12, 22, 32], [13, 23, 33]]
_Excel_RangeWrite($oWorkbook, 1, $aValues)
Global $iRed = 234 ; Hex 0xEA
$oWorkbook.Activesheet.Range("A1").Interior.Color = $iRed
$oWorkbook.Activesheet.Range("A3").Interior.Color = $iRed

; Get the max used range of the active sheet
$sMaxUsedColumn = _Excel_ColumnToLetter($oWorkbook.ActiveSheet.Usedrange.Columns.Count)
; Loop through all rows and check column A for a red cell. If found, read all used cells of this row and display the array.
For $i = 1 To $oWorkbook.ActiveSheet.Usedrange.Rows.Count
    If $oWorkbook.Activesheet.Range("A" & $i).Interior.Color = $iRed Then
        $aUsedRow = _Excel_RangeRead($oWorkbook, $oWorkbook.Activesheet, $oWorkbook.Activesheet.Range("A" & $i & ":" & $sMaxUsedColumn & $i))
        _ArrayDisplay($ausedRow)
    EndIf
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...