ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro button (https://www.excelbanter.com/excel-programming/352402-macro-button.html)

LeBob

Macro button
 

Hi,

I've writtten a macro under VBA and associate it to a button (Display,
toolbar, form).
Is it possible to be connected with this button in my vba code to
modify its caption for instance :confused: ??
YES ???
Great !!
How ???

Thanks


--
LeBob
------------------------------------------------------------------------
LeBob's Profile: http://www.excelforum.com/member.php...o&userid=31185
View this thread: http://www.excelforum.com/showthread...hreadid=508563


Tom Ogilvy

Macro button
 
In the macro associated, you can do

Sub Btn_Click()
Dim btn as Button
set btn = Activesheet.Buttons(Application.Caller)
If lcase(btn.Caption) = "no" then
btn.Caption = "Yes"
elseif lcase(btn.Caption) = "yes" then
btn.Caption = "No"
end if
End Sub

--
Regards,
Tom Ogilvy

"LeBob" wrote in
message ...

Hi,

I've writtten a macro under VBA and associate it to a button (Display,
toolbar, form).
Is it possible to be connected with this button in my vba code to
modify its caption for instance :confused: ??
YES ???
Great !!
How ???

Thanks


--
LeBob
------------------------------------------------------------------------
LeBob's Profile:

http://www.excelforum.com/member.php...o&userid=31185
View this thread: http://www.excelforum.com/showthread...hreadid=508563




Tim Williams

Macro button
 
With ActiveSheet.DrawingObjects(Application.Caller)
..Text = "Clicked me!"
End With

Tim

"LeBob" wrote in
message ...

Hi,

I've writtten a macro under VBA and associate it to a button (Display,
toolbar, form).
Is it possible to be connected with this button in my vba code to
modify its caption for instance :confused: ??
YES ???
Great !!
How ???

Thanks


--
LeBob
------------------------------------------------------------------------
LeBob's Profile:
http://www.excelforum.com/member.php...o&userid=31185
View this thread: http://www.excelforum.com/showthread...hreadid=508563




LeBob[_2_]

Macro button
 

I will try that right now !!! :)

thanks everboby


--
LeBob
------------------------------------------------------------------------
LeBob's Profile: http://www.excelforum.com/member.php...o&userid=31185
View this thread: http://www.excelforum.com/showthread...hreadid=508563


Ken Johnson

Macro button
 
Hi LeBob, Tom and Tim,
the coding of buttons has been a very confused part of my thinking.
(Tom, I'm sure is very aware of this, he has corrected me in the not
too distant past). After seeing this thread I'm now amazed at just how
easy it is to code for buttons. How on earth did I managed to become so
confused in the past?
A big Thank You to all of you for helping me improve my VBA by
revealing such simple and very useful button code.
Ken Johnson



All times are GMT +1. The time now is 08:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com