mike@RPI4b3:~> uname -a
Linux MikesPI 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux
Running bookworm on a Pi4b
Version: 7.4.7.2 / LibreOffice Community
Build ID: 40(Build:2)
CPU threads: 4; OS: Linux 6.1; UI render: default; VCL: x11
Locale: en-US (C); UI: en-US
Raspbian package version: 4:7.4.7-1+rpi1+deb12u8
Calc: threaded
In one Sub I’ve ranges declared so:
valCol = 11
profitCol = 13
endRow = 18
valRange = currentSheet.getCellRangeByPosition(valCol,0,valCol,endRow)
oRange = valRange.getCellRangeByPosition(0,1,0,18)
profitRange = currentSheet.getCellRangeByPosition(profitCol,0,profitCol,endRow)
oRange = profitRange.getCellRangeByPosition(0,1,0,endRow)
Here it appears and I assumed that range.getCellRangeByPosition(...)
would declare a sub-range in the outer range, and it worked as I expected.
In a second Sub it doesn’t seem to work and I keep getting ‘IndexOutOfBoundsException’.
My hope is that by posting the second Sub here someone will see what I’m doing wrong.
Sub macroWrap
thisCol = 7
topRow = 3
endRow = topRow + 10
oRange = currentSheet.getCellRangeByPosition( _
thisCol, topRow, thisCol, endRow )
oRange.getCellByPosition(0,0).Value = 0
oRange.getCellByPosition(0,1).Value = 1
selectOK(oRange, "oRange = " & oRange.AbsoluteName )
'bRange = oRange.getCellRangeByPosition(0,1,0,endRow)
' IndexOutOfBoundsException
'bRange = oRange.getCellRangeByPosition(0,1,0,13)
' IndexOutOfBoundsException
'bRange = oRange.getCellRangeByPosition(0,1,0,endRow-1)
' IndexOutOfBoundsException
'bRange = oRange.getCellRangeByPosition(0,4,0,endRow)
' IndexOutOfBoundsException
'bRange = oRange.getCellRangeByPosition(0,4,0,endRow-1)
' IndexOutOfBoundsException
'bRange = oRange.getCellRangeByPosition(thisCol,1,thisCol,endRow)
' IndexOutOfBoundsException
'bRange = oRange.getCellRangeByPosition(thisCol,4,thisCol,endRow)
' IndexOutOfBoundsException
'bRange = oRange.getCellRangeByPosition(thisCol,4,thisCol,endRow-1)
' IndexOutOfBoundsException
bRange = currentSheet.getCellRangeByPosition(thisCol,4,thisCol,endRow)
selectOK(bRange, "bRange = " & bRange.AbsoluteName )
End Sub
selectOK() is just a Sub that selects the first parpameter and prints the second parameter in a MsgBox used primarily for debugging.
Thanks for a second set of eyes.
Mike