Ask Your Question
0

How do I update a named range using a calc macro?

asked 2019-12-26 16:12:58 +0200

jgvicke gravatar image

I know how to remove and add a named range using a macro, but that method breaks equations that reference a named range when it is deleted. Is there a way to directly modify the referenced cells of a named range by macro without using the delete/add method?

Thanks, John Vickers

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-12-26 18:28:13 +0200

jmz gravatar image

Hi,

You can change the referred cells with the "setContent" method of a com.sun.star.sheet.NamedRange object:

doc = thiscomponent
namedranges = doc.NamedRanges
myrange = namedranges.getByName("myrange")
myrange.setContent("$Sheet1.$B$1:$B$5")

Regards.

edit flag offensive delete link more

Comments

Worked like a charm! Thanks!

jgvicke gravatar imagejgvicke ( 2019-12-26 18:50:40 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-12-26 16:12:58 +0200

Seen: 51 times

Last updated: Dec 26 '19