Skip to content

Accept Worksheet object instead of String in findQueryInColumn and findQueryInRow#24

Merged
physics515 merged 2 commits into
mainfrom
copilot/find-query-in-column-accept-sheet-type
Jun 3, 2026
Merged

Accept Worksheet object instead of String in findQueryInColumn and findQueryInRow#24
physics515 merged 2 commits into
mainfrom
copilot/find-query-in-column-accept-sheet-type

Conversation

Copilot AI commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

findQueryInColumn and findQueryInRow accepted a worksheet name as String, requiring an internal wb.Sheets(name) lookup. The parameter should be a Worksheet object, consistent with how other functions in the library (e.g., fuzzyFind) handle sheet references.

Changes

  • findQueryInColumn.bas / findQueryInRow.bas: Changed searchWorksheet As StringsearchWorksheet As Worksheet; removed the Workbook/Sheets() lookup boilerplate since the caller now owns that resolution
  • README.md: Updated input docs for both functions to reflect the new type and calling convention

Before / After

' Before
common.findQueryInColumn("Sheet 1", "foo", "A:A")

' After
common.findQueryInColumn(ThisWorkbook.Sheets("Sheet 1"), "foo", "A:A")

Copilot AI changed the title [WIP] Update search worksheet input to accept Sheet type Accept Worksheet object instead of String in findQueryInColumn and findQueryInRow Jun 3, 2026
Copilot AI requested a review from physics515 June 3, 2026 17:27
@physics515 physics515 marked this pull request as ready for review June 3, 2026 17:28
Copilot AI review requested due to automatic review settings June 3, 2026 17:28
@physics515 physics515 merged commit 94455c1 into main Jun 3, 2026
1 check passed
@physics515 physics515 deleted the copilot/find-query-in-column-accept-sheet-type branch June 3, 2026 17:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the findQueryInColumn and findQueryInRow APIs to accept a Worksheet object (instead of a worksheet name String), aligning these helpers with other library functions (e.g., fuzzyFind) that operate on sheet objects directly.

Changes:

  • Changed findQueryInColumn and findQueryInRow to take searchWorksheet As Worksheet and removed the internal ThisWorkbook.Sheets(...) lookup.
  • Updated the README documentation to reflect the new calling convention for both functions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
README.md Updates parameter documentation to pass a Worksheet object.
findQueryInRow.bas Changes API to accept a Worksheet and removes workbook/sheet-name resolution.
findQueryInColumn.bas Changes API to accept a Worksheet and removes workbook/sheet-name resolution.
Comments suppressed due to low confidence (2)

findQueryInColumn.bas:17

  • ws.Range(searchColumn).Find currently passes after:=searchColumnLastCell, but searchColumnLastCell is declared later (method 2). This will raise a runtime error (type mismatch) and also makes the function unable to return row numbers > 32767 because it returns Integer. Remove the invalid after argument and change the function/variable types to Long so it works across the full Excel row range.
        Dim ws As Worksheet: Set ws = searchWorksheet
        Dim foundRow As Integer

        'find the search term within the search range
        Dim foundSearchTerm As range: Set foundSearchTerm = ws.range(searchColumn).Find(what:=searchTerm, after:=searchColumnLastCell, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False)

README.md:102

  • If findQueryInColumn returns a Long (needed for Excel's full row range), the README output type should be updated to match to avoid misleading callers.
1. `Worksheet` Search Worksheet _(ex. ThisWorkbook.Sheets("Sheet 1"))_
2. `String` Search Term _(ex. "foo")_
3. `String` Search Column _(ex. "A:A")_

**Output**: `Integer` Row Number

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread findQueryInRow.bas
Comment on lines +6 to 10
'receives input of worksheet (ex. ThisWorkbook.Sheets("Sheet 1")), search term (ex. "foo"), and range (ex. "1:1") as string
'outputs column number as integer

Function findQueryInRow(searchWorksheet As String, searchTerm As Variant, searchRow As String) As Integer
Function findQueryInRow(searchWorksheet As Worksheet, searchTerm As Variant, searchRow As String) As Integer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find Query In Column - Should accept a Worksheet as type Sheet

3 participants