cycle through Cells in a Range

In Excel VBA you can say:

For c In aRange
  doSomethingToC
Next

I’m struggling to do the same in LO Basic.
Pitonyak’s code in OOME
Listing 418. Find cells that are not empty in a range.

Function NonEmptyCellsInRange(oRange, sep$) As String  

doesn’t do exactly what I want so am trying to generalize but keep getting errors I don’t understand, so if some can point me in the right direction I’d appreciate it.
I’m trying to find a way to effect every cell in a cellRange in calc and can’t find the proper way to use
getCells or getRangeAddresses.
Given:

StocksOds = ThisComponent
ETFsSheet = StocksOds.CurrentController.ActiveSheet
REM All the following give not found errors:
oAddrs() = oRange.getRangeAddresses() 	'	Err#423: getRangeAddresses not found
oAddrs() = ETFsSheet.oRange.getRangeAddresses() 	'	Err#423: oRange not found
oCells() = StocksOds.oRange.getCells() 	'	Err#423: oRange not found
oCells() = StocksOds.CurrentController.oRange.getCells() 	'	Err#423: oRange not found

Specifically what is the correct way to call oRange.getRangeAddresses() or oRange.getCells()?

Thanks,
Mike

Are you sure you need getRangeAddresses? It is a method of com::sun::star::sheet::XSheetCellRanges. Are you sure you pass that as oRange to your function? Or is that com::sun::star::sheet::XCellRangeAddressable, which has getRangeAddress?

If you have knowledge of how to accomplish my task feel free to pass it on.

Questioning my question seems counter productive.

Of course I’m not sure else I wouldn’t be wasting the forums time.

Be well, Mike

Questioning my question seems counter productive

OK, bye. Just a note. Questioning a question means you have not provided enough info. Or else other would know what to answer without asking for additional info. Of course, nowhere in your question you mention what you are actually passing to the function, how you call it in code. And replying to those who try to help with your vision what those people should do from your PoV seems counter productive.

Having restated the question more generally I found this to work:

Sub walkRange(oRange) 
' based on Sasa Kelecevic Sub FillCells
' from AndrewMacros.odt
' Listing 6.20: Iterate through cells and set the text.
  oColumns=oRange.Columns 
  oRows=oRange.Rows
  For nc= 0 To oColumns.getCount-1
    For nr = 0 To oRows.getCount-1
'      oCell=oRange.getCellByPosition (nc,nr).setString ("OOOPS")
      oCell=oRange.getCellByPosition (nc,nr)
      doSomethingtoCell(oCell)		'	this works
    Next nr
  Next nc
End Sub

Be Well,
Mike

I've since learned that ranges.getCells() and ranges.cells only work for SheetCellRanges but not SheetCellRange objects, likewise oRanges.getRangeAddresses().

Ciao

This is the common way to loop through the cells of a range if you actually need them as “objects” (meaning that all the services available for a single cell must be supported).
If you want to work with the content only, you can use the DataArray and/or the FormulaArray.
Be aware of the fact that you need to first call the get method for the array, and finally the set method.

Questioning questions can be an appropriate means when trying to help. A (relative) beginner should accept it anyway. Experienced users will take his criticism more serious if progress in learning is clearly shown.

Let’s practice proper respect concerning others and let’s also not be too easily irritable.

Generally: Don’t think VBA if you are programming for LibreOffice. VBA seems to try to be language and API at the same time. LibreOffice Basic is very different: A simple, (some say rudimantary) language. It comes with an editor supporting debugging to some degree, and with an interpreter running the code, of course. All the power isn’t provided by Basic, but by the API which also can be used when programming in (e.g.) Python.