在 VBA Libreoffice 中获取 FindFirst 结果的行号
Get row number of a FindFirst result in VBA Libreoffice
我有一个函数可以在包含值的列中查找第一个单元格:
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
包含"select"的行选择了好的单元格,但我想得到单元格的行号而不选择它。我试过了
resultat.Row
但是没用。谁能帮帮我吗?
谢谢
我从未使用过 LibreOffice,我不会说法语,但如果您的 VBA 类似于 Excel VBA 那么您可能使用了不正确的方法。
Excel 中没有 FindFirst
(与 Access 不同),但是有一个 Find
方法。
以下VBAreturns第一个匹配的行号:
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
我自己找到的:
Msgbox "Row: " + resultat.cellAddress.Row
我有一个函数可以在包含值的列中查找第一个单元格:
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
包含"select"的行选择了好的单元格,但我想得到单元格的行号而不选择它。我试过了
resultat.Row
但是没用。谁能帮帮我吗? 谢谢
我从未使用过 LibreOffice,我不会说法语,但如果您的 VBA 类似于 Excel VBA 那么您可能使用了不正确的方法。
Excel 中没有 FindFirst
(与 Access 不同),但是有一个 Find
方法。
以下VBAreturns第一个匹配的行号:
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
我自己找到的:
Msgbox "Row: " + resultat.cellAddress.Row