View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy Doug Glancy is offline
external usenet poster
 
Posts: 770
Default Which button did I push

Daniel,

Application.Caller returns the name of the calling button:

Select Case Sheet1.Buttons(Application.Caller).Top
Case Is 100
Range("c10").Interior.ColorIndex = 5
Case Is <= 100
Range("c50").Interior.ColorIndex = 5
End Select

hth,

Doug Glancy

"Daniel Bonallack" wrote in message
...
I have two command butons on an Excel page, both assigned
to the same macro. Let's say the function of the macro
is to make the cell to the right of the button blue shade.

How can I tell which button was pushed?

For example:

Sub WhichButton

Select Case ButtonPushed.Top
Case 100
Range("c10").interior.colorindex = 5
Case <=100
Range("c50").interior.colorindex = 5
End Select

End Sub

Thanks
Daniel