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 ^^’)