ACF Library

FindDataRow

Back to List

Description: Locates a specific label in the first column (column A) of a given sheet.

FileMaker Prototype:

Set Variable [$res; ACF_Run("FindDataRow"; int_s;  int_start;  string_name)]

Category: EXCEL

Function source:

// Function: FindDataRow
// Description: Locates a specific label in the first column (column A) of a given sheet.
//              Searches from a specified starting row and returns the row number where the label is found.
// Parameters:
//   - s: The sheet identifier (integer).
//   - start: The starting row number for the search.
//   - name: The label (string) to search for in column A.
// Returns:
//   - The row number (integer) where the label is found.
//   - Returns -1 if the label is not found.

function FindDataRow(int s, int start, string name) 
    int i;  
    int rc = Excel_GetRowCount(s); // Get the total number of rows in the sheet
    string cellValue; 

    // Iterate through the rows starting from the specified row
    for (i = start, rc ) 
        // Get the value from column A (column 1 in zero-based indexing)
        cellValue = Excel_GetCell(s, i, 1); 

        // Check if the cell value matches the target name
        if (cellValue == name) then
            return i; // Return the row number where the label was found
      end if
   end for

    // Return -1 if the label is not found in any row
    return -1; 
end

Back to List