How to make a checkbox change according to data in another cell?

From Apache OpenOffice Wiki
< Documentation‎ | FAQ‎ | Calc‎ | Miscellaneous
Revision as of 14:55, 4 November 2008 by Ufi (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


How to make a checkbox change according to data in another cell?


In Calc enter this function
'=IF(A1=1;"True";"False")'

Now, you need to add this macro. If you don't know how, please see the user guide.

 Sub SetMyCheckBox
 Dim oForm
 Dim oControl
 Dim oSheet
 Dim oCell

	oForm = ThisComponent.Sheets(0).DrawPage.Forms.getByIndex(0)
	oControl = oForm.getByName("MyCheckbox")
	oSheet = ThisComponent.Sheets(0)
	oCell = oSheet.getCellRangeByName("A1")

	If oCell.Value = "1" then
		oControl.Value = "True" (?)
	Else
		oControl.Value = "False"
	End If
 End Sub


Personal tools