Ask Your Question

Naming sheet tabs

asked 2018-11-20 21:37:04 +0100

Pete of Ebor gravatar image

updated 2020-09-16 11:09:38 +0100

Alex Kemp gravatar image

I suspect there isn't, but I'll ask anyway... Is there any way to dynamically name and rename sheet tabs in calc ? For example, I may want to change the tab name to mirror the text string in a particular cell ?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-11-20 22:23:34 +0100

Lupp gravatar image

updated 2018-11-20 22:44:55 +0100

Thinkable rules for naming sheets are so manifold that I cannot imagine a tool automatimg it in a way needing less input than direct renaming per sheet. If you actually think to need an automatism for one specific rule (first word from cell A1 e.g.) you can implement it by rather simple user code. However, you have to provide a handling for the case that action cannot be performed. You cannot have two sheets with the same name e.g.
Example code in Basic:

REM  *****  BASIC  *****
Sub nameSheetsA1()
doc0          = ThisComponent
theSheets     = doc0.Sheets
For Each oneSheet in theSheets
  strA1         = oneSheet.getCellRangeByName("A1").String
  renameSheet(oneSheet, Split(strA1, " ")(0))
Next oneSheet
End Sub

Sub renameSheet(pSheet As Object, pNewName) As String
On local Error Goto lError
pSheet.Name = pNewName
Goto ok
MsgBox("Action ""renameSheet"" failed.")
End Sub

BTW: You don't name the tabs but the sheets. The tabs are a kind of labels showing the sheet names.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-11-20 21:37:04 +0100

Seen: 247 times

Last updated: Nov 20 '18