Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
PaulW
 
Posts: n/a
Default Variable Text on a Button

For most macros I make, I use a Button, from the Forms taskbar to execute it.

What I want to do is set up a Button that runs 2 macro's, depending on what
was last run. I've done this easily before by setting both scripts in the
same macro, and a simple IF statement to look at a cell that is change at the
end of each macro. An example is it changes from "Automatic" to "Manual" and
this removes or adds forumlas in certain cells.

My question is, can I change the text on the button dependant on cells? So
if A1 is 1, the button says "Automatic" and if A1 is 0 the button reads as
"Manual" ?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Variable Text on a Button

'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "A1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 1 Then
Me.Buttons("Button 2").Caption = "Automatic"
Else
Me.Buttons("Button 2").Caption = "Manual"
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"PaulW" wrote in message
...
For most macros I make, I use a Button, from the Forms taskbar to execute

it.

What I want to do is set up a Button that runs 2 macro's, depending on

what
was last run. I've done this easily before by setting both scripts in the
same macro, and a simple IF statement to look at a cell that is change at

the
end of each macro. An example is it changes from "Automatic" to "Manual"

and
this removes or adds forumlas in certain cells.

My question is, can I change the text on the button dependant on cells? So
if A1 is 1, the button says "Automatic" and if A1 is 0 the button reads as
"Manual" ?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM
Text Wrapping JMB Excel Discussion (Misc queries) 0 July 29th 05 02:41 AM
Converting variable text strings to numeric Richgard53 Excel Discussion (Misc queries) 1 July 13th 05 06:22 AM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 03:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"