Code: Select all
sub roundAllCells
dim oFunAccess as object
oFunAccess = createUnoService( "com.sun.star.sheet.FunctionAccess" )
for each oSheet in ThisComponent.Sheets
oCurs = oSheet.createCursor()
oCurs.gotoEndOfUsedArea(True)
num_row = oCurs.Rows.Count
num_col = oCurs.Columns.Count
for i=0 to num_row-1
for j=0 to num_col-1
oCell = oSheet.getCellByPosition(j,i)
if oCell.type = 1 then
oCell.value = oFunAccess.CallFunction( "round", array(oCell.value,2))
end if
next j
next i
next
end sub
Edit: Changed subject, was How can simplify the function to round all cells whose type is number? Make your post understandable by others -- MrProgrammer, forum moderator |