【发布时间】:2021-01-25 12:08:48
【问题描述】:
我使用了在网上论坛上找到的宏。
它检测指定单元格的背景颜色并返回该背景颜色的数值。问题是它只执行一次。当我更改指示单元格的背景颜色时,数值不会更新。 要更新它,我必须更改调用宏的单元格中的某些内容(例如,删除一个字符并重新输入),然后按 Enter。然后更新数值。
有没有办法让它自动更新?或者,是否有更简单的方法来更新它(与描述的删除和重新输入方法相比),最好是一次在多个单元格上工作的方法。
Villeroy 在 openoffice 论坛上编写的代码:
Function CELL_BACKCOLOR(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM returns color code as number
Dim v
v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
if vartype(v) = 9 then
CELL_BACKCOLOR = v.CellBackColor
else
CELL_BACKCOLOR = v
endif
End Function
Function getSheetCell(byVal vSheet,byVal lRowIndex&,byVal iColIndex%)
dim oSheet
' print vartype(vsheet)
oSheet = getSheet(vSheet)
if varType(oSheet) <>9 then
getSheetCell = NULL
elseif (lRowIndex > oSheet.rows.count)OR(lRowIndex < 1) then
getSheetCell = NULL
elseif (iColIndex > oSheet.columns.count)OR(iColIndex < 1) then
getSheetCell = NULL
else
getSheetCell = oSheet.getCellByPosition(iColIndex -1,lRowIndex -1)
endif
End Function
【问题讨论】:
标签: openoffice-calc openoffice-basic