Accept Worksheet object instead of String in findQueryInColumn and findQueryInRow#24
Merged
Merged
Conversation
…dQueryInColumn and findQueryInRow
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
There was a problem hiding this comment.
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
findQueryInColumnandfindQueryInRowto takesearchWorksheet As Worksheetand removed the internalThisWorkbook.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).Findcurrently passesafter:=searchColumnLastCell, butsearchColumnLastCellis 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 returnsInteger. Remove the invalidafterargument and change the function/variable types toLongso 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
findQueryInColumnreturns aLong(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 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
findQueryInColumnandfindQueryInRowaccepted a worksheet name asString, requiring an internalwb.Sheets(name)lookup. The parameter should be aWorksheetobject, consistent with how other functions in the library (e.g.,fuzzyFind) handle sheet references.Changes
findQueryInColumn.bas/findQueryInRow.bas: ChangedsearchWorksheet As String→searchWorksheet As Worksheet; removed theWorkbook/Sheets()lookup boilerplate since the caller now owns that resolutionREADME.md: Updated input docs for both functions to reflect the new type and calling conventionBefore / After