Hello. I am in need of some help please. Being new here and not really a programmer, what I want to do I think is really simple.
Really don't understand why it does not work.
In Calc, I have 12 sheets.
The source sheet is sheet 1 (with the first sheet being 0 as I have learned) that has columns from A to K
There are 10 destination sheets with the first one starting at sheet 2. They contain no data.
What I need to do is copy rows starting in column B from the source (sheet 1) into the destination sheet (sheet 2) and then repeat until rows in column B though column K are copied into
the sheets 2 to 12. The column destination will always remain in the same place, column 1.
I can kinda get this to work but have run into an error that does not make sense to me.
Here is the code (sorry I do not know how to paste it the code area):
Code: Select all
sub copy_range_and_paste_it_to_another_cell
oSheet = thisComponent.Sheets.getByIndex(1)
oSheet1 = thisComponent.Sheets.getByIndex(2)
source = oSheet.getCellRangeByPosition(1,0,0,100).getRangeAddress()
destination = oSheet1.getCellByPosition(1,0).getCellAddress()
oSheet.copyRange( destination , source )
End sub
The issue is this. When I change the getCellRangeByPosition from 0 to 1, which I think would be the next column to get my source from, I get this error:
IndexOutOfBoundsException
If I leave it a 0 then it copies column 0 into my source sheet. Why cannot I set the source to be column 1 from the source sheet, there is data there.
Please be so kind to help me.
Thank you,
Dennis