Hello, this patch might be a bit to big for 3-4, but who knows: http://cgit.freedesktop.org/libreoffice/core/commit/?id=04d2e6469529b6187900659517d6f6dd5ea2cca5 We have three related problems: -database range tokens must be adjusted when we copy between different documents -global/local range name tokens must be updated when we copy between different documents -local range name tokens must be updated when we copy them between different sheets If we don't update the tokens in the formula cells they may point to different entries after the copy process. I think we have an additional related problem that might be gone with this patch. If we have an external sheet it will be copied when we load the file. This seems to result in some corner case that the range names in formulas are messed up. I haven't found the bug report for this problem at the moment. The idea behind this patch is quite simple. For every ScNameToken we need to update the index and for all range names also set the flag for local/global range names. For range names we first extract the name and then search for the name in the local and global range name container, then we can set the token to the correct index and set the local/global flag. For database ranges we only have a global container, so we just need to get the database data name and then search for this name in the new database range container. I plan to use this as a base for changing the copy/paste code in master: we can use this code to remove the part that copies all range names to the new document/sheet. Instead we can now only copy the relevant range names to the new document. Regards, Markus