Search bar with highlight - Basic Code

Good morning all,
I have a slight concern. I should be able to highlight one or more lines based on the user’s search result. The search would be based on the first column. Example: Column 1: AB1, AB2, AB3;
If I type “AB1”, it highlights the whole line that corresponds to this cell.
I have code in Visual Basic, but unfortunately VBASupport 1, but Libreoffice does not take into account all the functionalities of Visual Basic
Here is my code in Visual Basic done on Excel

Option Compare Text

Private Sub TextBox1_Change()
Application.ScreenUpdating = False

Range("A2:A10000").Interior.ColorIndex = 2
Range("B2:B10000").Interior.ColorIndex = 2
Range("C2:C10000").Interior.ColorIndex = 2
Range("D2:D10000").Interior.ColorIndex = 2
Range("E2:E10000").Interior.ColorIndex = 2

If TextBox1 <> "" Then
    For Ligne = 2 To 10000
        If Cells(Ligne, 1) Like "*" & TextBox1 & "*" Then
            Cells(Ligne, 1).Interior.ColorIndex = 43
            Cells(Ligne, 2).Interior.ColorIndex = 43
            Cells(Ligne, 3).Interior.ColorIndex = 43
            Cells(Ligne, 4).Interior.ColorIndex = 43
            Cells(Ligne, 5).Interior.ColorIndex = 43
        End If
    Next
End If

End Sub

After that I tried to do it in “Basic” but I have big difficulties.

REM  *****  BASIC  *****

Option VBASupport 1
Sub Main
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)
Doc = ThisComponent
MySheet = Doc.CurrentController.ActiveSheet

dim Range
Range = MySheet.getCellRangeByName("A2:A10000") // Color ?
Range = MySheet.getCellRangeByName("B2:B10000") // Color ?
Range = MySheet.getCellRangeByName("C2:C10000") // Color ?
Range = MySheet.getCellRangeByName("D2:D10000") // Color ?
Range = MySheet.getCellRangeByName("E2:E10000") // Color ?


If TextBox1 <> "" Then
    For Ligne = 2 To 10000
        If Cells(Ligne, 1) Like "*" & TextBox1 & "*" Then
            Cells(Ligne, 1).Interior.ColorIndex = 52224
            Cells(Ligne, 2).Interior.ColorIndex = 52224
            Cells(Ligne, 3).Interior.ColorIndex = 52224
            Cells(Ligne, 4).Interior.ColorIndex = 52224
            Cells(Ligne, 5).Interior.ColorIndex = 52224
        End If
    Next
End If

End Sub
Here is the result I would like :

If anyone could give me help I would thank you very much!
(Sorry for my bad english ^^’)

I think that the distinguished colleague @Lupp gave great advice. I will only illustrate his idea.

ColorizeWithoutMacro.ods

Since I know that the distinguished colleague @JohnSUN also is interested in user code, I attach this (was:ask232572highlightFindings_1.ods) example I sketched in pursuit of this question in a playful mood.

Thank you, my friend, as always succinctly and efficiently. And we both understand that this is nothing more than a joke. (“I could have come up with a more complicated way”, the White Queen proudly stated)

You resolve my problem ! Thanks a lot !!
Mathieu.

Assigning cell attribute values to highlight cells (ranges) conditionally is the wrong way. Assigned attributes or cell styles will persist if the item(s) on which the condition is based change values.

Put the “search item” (string or number) you are looking for into a dedicated cell and use Conditional Formatting (CF) to highlight the cell ranges meeting the condition.

There are many advantages. As I see it, some important ones are:
Efficiency: The evaluation of the conditions is only made for the cells inside the view. That’s fast!
Structure: CF is fully compatible with the well designed usage of named cell styles. No attribute patching!
Economy: Overlaid styles don’t need explicit removal when conditions no longer are met.

If you actually need persistent assignments please state this explicitly, and include your ideas about what shall happen if the item on which the attribute setting was based gets changed.

Put the “search item” (string or number) you are looking for into a dedicated cell and use Conditional Formatting (CF) to highlight the cell ranges meeting the condition.

Can you help me on conditional formatting (CF) to highlight cell ranges? Or if you don’t want, a guide on LibreOffice that would allow me to get there?
I am a beginner in Basic
Thank you for your reply !

(Please don’t use the ‘Answer’ option for comments, additional questions, and discussions about aspects of posts. Depending on the specific case the appropriate action is either to edit your own post, whether question or answer, or to add a comment on a full post by anybody.)

The most recent guides and general documentation you find here. I pointed you to the English page because I don’t know anything about the state of the documentation in different languages.

The suggestion to use CF doesn’t include Basic macros. The user interface provides perfect means to use CF.without any programming.

It may be seen as a disease of Excel that users are encouraged to “solve” their problems by lots of (often poor) VBA code. I see the VBA pool as a main part of the strategy of MS to perpetuate the “market leader” position by enforcing incompatibilities with better(?) free and open source software.