You can assign the value of a property in response to an event, such as a click on a command button, by adding a SetValue action to a macro or by using an assignment statement in a Visual Basic procedure.
Set the value of a property in response to an event by using a macro
Set the value of a property in response to an event by using Visual Basic for Applications