View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default click buttons to do, re-click to un-do

Hi
one way: Declare a static variable. e.g.

----
Private Sub CommandButton1_Click()
Static status As Boolean
If status Then
' your code for undoing something
CommandButton1.Caption = "Do something"
status = False
Else
' your code for doing something
CommandButton1.Caption = "Undo something"
status = True
End If

End Sub

--
Regards
Frank Kabel
Frankfurt, Germany

Hello all,

I would like to add a button in a spreadsheet and have it do an
operation when cliked and undo the same operation when clicked again.

how do I do this?

Could someone help me write the code?

Thanks


---
Message posted from http://www.ExcelForum.com/