How can I have a Sheet Name reflect a Cell ?

General discussion on OpenOffice Calc and its spreadsheets.

How can I have a Sheet Name reflect a Cell ?

Postby Joseph S. Klein » Sat Oct 11, 2014 5:56 am

Hi guys,

I am using this to Change the name of My Sheet to reference a Cell for its name. It works when I change that Specific Cell but when I put data anywhere else it changes back to the Default one I select. Ultimately I want the Cell to be labeled CX1 if the K4 is Empty but Keep the Name if K4 is Populated. Any suggestions ? Thank you!

sub CX1(event)
on Error resume next
if right(event.AbsoluteName, 4 ) = "$K$4" and event.String <> "" then
event.Spreadsheet.Name = event.String
else
event.Spreadsheet.Name = "CX 1"
end if
end sub
Joseph S. Klein
 
Posts: 38
Joined: Mon Mar 24, 2014 6:28 am

Re: How can I have a Sheet Name reflect a Cell ?

Postby Champ_AN » Sat Oct 11, 2014 7:22 am

Hi,

Please try the code given bellow:
Code: Select all
Sub Main(event)
'print oEv.AbsoluteName
oSheet = event.Spreadsheet
K4 = oSheet.getCellRangeByName("K4")
if K4.String <> "" then
   oSheet.Name = K4.String
else
   oSheet.Name = "CX 1"
End If
End Sub

Hope this will help you.
Thanks,
Champ_AN
 
Posts: 19
Joined: Tue Mar 25, 2014 6:34 am


Return to OpenOffice.org Calc

Who is online

Users browsing this forum: No registered users and 1 guest

cron