Reputation: 2137
I have a function finding the first cell in a column containing a value:
recherche = colonneRecherche.createSearchDescriptor
with recherche
.SearchString = valeur
.SearchCaseSensitive = false
.SearchByRow = true
.SearchWords = false
end with
resultat = colonneRecherche.findFirst(recherche)
if isnull(resultat) then
RechercherValeur = "NO RESULT!"
Exit Function
else
thisComponent.CurrentController.select(resultat)
a.nom = "TEST"
RechercherValeur = a
Exit Function
End If
The line containing "select" selects the good cell, but I'd like to get the row number of the cell without selecting it. I tried
resultat.Row
But it doesn't work. Can anyone help me please? Thanks
Upvotes: 2
Views: 902
Reputation: 2137
I found it by myself:
Msgbox "Row: " + resultat.cellAddress.Row
Upvotes: 1
Reputation: 21639
I've never used LibreOffice and I don't speak French, but if your VBA is like Excel VBA then you may be using an incorrect method.
There is no FindFirst
in Excel (unlike Access), however there is a Find
method.
The following VBA returns the row number of the first match:
Sub testFind()
Dim ws As Worksheet, f As Range
Set ws = Sheets("Sheet1")
Set f = ws.Cells.Find("abc")
If f Is Nothing Then
MsgBox "Not found"
Else
MsgBox "Found on row: " & f.Row
End If
End Sub
Upvotes: 0