Hi everyone,
I was creating my vocabulary log using Libre Office Spreadsheet (ver 6.0.6.2) recently, and now I have several sheets with about 50 vocabulary in each of them. I would like to create a range name for each of the word using macro. For example, I would like to add a range name “apotheosis” for the range $2:$2, and “arch” for the range $3:$3… etc.
and here is my macro code
An error will occur in line 14 when I run it, can someone tell me what the last half 2 arguments in the addNewByName parentheses mean? or what am I missing?
(I’ve tried the method on this page, but it doesn’t work.
I also read the official guide too, but it doesn’t work either)
Thanks a lot!
===Updates 2018.10.22===
I’m really grateful for the quick reply from everyone. The following is the revised version:
Sub Main
Dim Doc, MySheet, MyRange, TheRange, Cel as Object
Dim i as integer
Doc = ThisComponent
MySheet = Doc.Sheets(14)
TheRange = Doc.NamedRanges
For i = 1 to 51
Cel = MySheet.getCellByPosition(0,i)
MyRange = MySheet.rows(i)
If NOT TheRange.hasByName(Cel.string) Then
TheRange.addNewByName(Cel.string, MyRange.absoluteName, Cel.CellAddress, 0)
Else
End If
next
End Sub