starting with a workbook with the following sheets 'sheet1', 'sheet2' and
'sheet3'
and trying a macro like:
sub test
worksheets.copy after:=worksheets(2)
end sub
results in the following sheets in the workbook 'sheet1', 'sheet2',
'sheet1_2', 'sheet2_2', 'sheet1_2_2', 'sheet3'
the expected result should be something like 'sheet1', 'sheet2',
'sheet1_2', 'sheet2_2', 'sheet3_2', 'sheet3'
and similarly running the following macro
sub test
worksheets.copy before:=worksheets(2)
end sub
results in a workbook with the following sheets 'sheet1', 'sheet1_2',
'sheet1_2_2', 'sheet1_2_2_2', 'sheet2', 'sheet3'
expected results would be 'sheet1', 'sheet1_2', 'sheet2_2', 'sheet3_2',
'sheet2','sheet3'
I think you are falling victim to the fact that you are modifying the
underlying container ( e.g. the sheets container ) whilst iterating over it.
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.