Dynamic Button Name?

Hi everone,

Can a button name be made dynamic?

For example, you create a button and want its name be read from cell
A1. So if A1 read "Mike", the button name automatically become "Mike"
and so on.

Thanks,
Mike

0
2/8/2005 1:15:22 PM
excel 39879 articles. 2 followers. Follow

8 Replies
840 Views

Similar Articles

[PageSpeed] 41

for a button from the Forms toolbar, you can use this event macro. Put 
it in the worksheet code module (right-click the worksheet tab and 
choose View Code")

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
        If Not Intersect(Target, Range("A1")) Is Nothing Then _
            Me.Buttons(1).Caption = Range("A1").Value
    End Sub




In article <1107868522.200800.123520@g14g2000cwa.googlegroups.com>,
 "Mike" <mas_it_2000@yahoo.com> wrote:

> Hi everone,
> 
> Can a button name be made dynamic?
> 
> For example, you create a button and want its name be read from cell
> A1. So if A1 read "Mike", the button name automatically become "Mike"
> and so on.
> 
> Thanks,
> Mike
0
jemcgimpsey (6723)
2/8/2005 1:28:09 PM
You can put following code in your worksheet.
Here, put the correct button name!
===================================================
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
        commandbutton1.Caption = Target.Text
    End If
End Sub
===================================================
Hope this helps.

~Yogendra

0
2/8/2005 1:48:40 PM
Thank you JE and Yogendra.

However, I already have a macro under that button like this:

Sub UnhideSubsystem1()
    Range("System").Select
    Selection.EntireRow.Hidden = False
End Sub

How this would become after I add your "Private Sub" to it?

Mike

0
2/8/2005 2:36:17 PM
Mike

JE's code would be in addition to the code you have assigned to the button.

The code is event code and is fired when a change is made in A1 and will
change the Button Nmae to whatever you entered in A1.

Don't touch your existing code.

Right-click on the worksheet tab and "View Code".

Copy/paste JE's code into that module.


Gord Dibben Excel MVP

On 8 Feb 2005 06:36:17 -0800, "Mike" <mas_it_2000@yahoo.com> wrote:

>Thank you JE and Yogendra.
>
>However, I already have a macro under that button like this:
>
>Sub UnhideSubsystem1()
>    Range("System").Select
>    Selection.EntireRow.Hidden = False
>End Sub
>
>How this would become after I add your "Private Sub" to it?
>
>Mike

0
Gord
2/8/2005 5:06:58 PM
I tried this but not working! Let me explain one thing please. I have 4
buttons, each is assigned to a sub. The 4 subs are in one module. Each
button is assigned to one sub.

Two questions: take button #1
1)It is already assigned to sub #1, how would I assign it to JE's sub?
2)How would I put sub #1 and JE's sub togother? Next to each other like
this:

Sub UnhideSubsystem1()
    Range("System").Select
    Selection.EntireRow.Hidden = False
End Sub

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
        If Not Intersect(Target, Range("A1")) Is Nothing Then _
            Me.Buttons(1).Caption = Range("A1").Value
    End Sub 

Thanks,
Mike

0
2/8/2005 5:44:48 PM
JE's code wouldn't be assigned to the button.  It's the worksheet event that
actually adjusts the caption of the button (from the Forms toolbar).

And my question:  Don't you want the button to run the same sub--no matter what
the caption is?  If that's true, you shouldn't need to reassign any macro to
that button.

On the other hand, if you want to run different code based on the caption, then
you'll have to share those details.

ps.

Read JE's post once more.  You'll see that his code doesn't go into a general
module (like your 4 subroutines).  It goes behind the worksheet that should have
that "recaption the button" behavior.



Mike wrote:
> 
> I tried this but not working! Let me explain one thing please. I have 4
> buttons, each is assigned to a sub. The 4 subs are in one module. Each
> button is assigned to one sub.
> 
> Two questions: take button #1
> 1)It is already assigned to sub #1, how would I assign it to JE's sub?
> 2)How would I put sub #1 and JE's sub togother? Next to each other like
> this:
> 
> Sub UnhideSubsystem1()
>     Range("System").Select
>     Selection.EntireRow.Hidden = False
> End Sub
> 
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
>         If Not Intersect(Target, Range("A1")) Is Nothing Then _
>             Me.Buttons(1).Caption = Range("A1").Value
>     End Sub
> 
> Thanks,
> Mike

-- 

Dave Peterson
0
ec357201 (5290)
2/8/2005 10:30:31 PM
If I to assign JE code to the worksheet, and since I need to make each
of the 4 buttons have a dynamic name read from a different cell, how
the worksheet would recognize that?

Again, I need to make each button has a dynamic name read from a cell.
So, how JE code here would be used?

Mike

0
2/9/2005 11:51:49 AM
One way:

  Private Sub Worksheet_Change(ByVal Target As Excel.Range) 
     If Not Intersect(Target, Range("A1, B2:B3, D4")) Is Nothing Then
       Me.Buttons(1).Caption = Range("A1").Text
       Me.Buttons(2).Caption = Range("B2").Text
       Me.Buttons(3).Caption = Range("B3").Text
       Me.Buttons(4).Caption = Range("D4").Text
     End If
   End Sub 



In article <1107949908.976484.210820@f14g2000cwb.googlegroups.com>,
 "Mike" <mas_it_2000@yahoo.com> wrote:

> If I to assign JE code to the worksheet, and since I need to make each
> of the 4 buttons have a dynamic name read from a different cell, how
> the worksheet would recognize that?
0
jemcgimpsey (6723)
2/9/2005 2:17:51 PM
Reply:

Similar Artilces:

Controling queries displayed when clicking Load from Query button?
I want to be able to control the queries that are displayed when the Load from Query toolbar button is displayed. Can anyone tell me how the filter box list gets populated? Thanks. Paco ...

service calendar in MS Dynamics 4.0
Does anyone knows how we can achieve the following requirement with MSCRM 4.0 In the service calendar in MS Dynamics 4.0 you are able to create new appointments and service activities. Appointments and Service Activities which are created will be present in the Service Calendar. To see all details of such a record[Subject(default Value)] you must open it. But by moving your mouse on the concerning appointment or service activity, a text-box-view appears with primary information. With appointments the content of the following fields is displayed: 'show time as', 'subject...

How to revert back to the original file name in a hyperlink
I have an excel file with 2500 linked objects in it. All the linked objects are given with a name for eg. "SCAN". I want to change these names in the "test to display" column for all the cells in one go. Is it possible ? ...

How to change the the attribute's name???
Hi Group: I would like to know if it is possible to change the name of an attribute to something else. My setup is like this: I have serveral SQL tables that I nest and join so that it all outputs into a nice XML file for the purpose of populating a flash navigation menu. <NewDataSet> <mainMenu_category menu_name="Home" menu_ID="1"> <menu menu_ID="1" /> </mainMenu_category> <mainMenu_category menu_name="Product" menu_ID="2"> <menu category_name="28.5 Volt DC Power Carts" menu_...

Stop named ranges being copied
I want to copy a worksheet from one workbook to another. But I do not want to copy the named ranges associated with the first workbook to the second. How do I prevent named ranges being copied when I move sheets. >>How do I prevent named ranges being copied when I move sheets. You can't. A named range is just as much a part of a sheet as anything else. Delete the name(s) after you copy a sheet. -- Jim <bmatheson@gmail.com> wrote in message news:1183722346.818571.213860@q75g2000hsh.googlegroups.com... >I want to copy a worksheet from one workbook to another. > >...

dynamic resource
Hi, Anybody know how to load e.g. bitmap into resource dynamicaly? The bitmap file will be downloaded by application itself , so it has to be somehow inserted into resource and displayed. thanks What do you mean by "into resoure dynamically"? Do you want to load a ..bmp file and display it? If yes, take a look at GDI+, which is by far the easiest way to achieve this. ---------- Ajay Kalra ajaykalra@yahoo.com I misspelled this, yes I'd like to load new bitmap on the fly. But resource file looks like is static. I use ATL/MFC applicatation. "Ajay Kalra" <aja...

Dynamic sum in Chart
Hello: So I've got this pivot chart that I've created, and it's great, EXCEPT when I select different categories to show up, I want to show a SUM of the categories, not the values of each category. I would appreciate any help/advice you may have. Thank you! Michelle In the pivot table you can select different thing like count and SUM etc. If you right click in the upper left vacant square and chose field settings, then select what you want to see in your data section. Misha wrote: > Hello: > > So I've got this pivot chart that I've created, and it's great...

Naming a formfield
I am using Word 2003, I have added a formfield with code as shown below, declared the ffield as a formfield but the code is debugging with object variable not set for some reason on the '.Name'. I have successfully used this bit of code in other templates I have created. Can anyone offer me an alternative or solution please? Set ffield = _ ActiveDocument.FormFields.Add(Range:=Selection.Range, _ Type:=wdFieldFormTextInput) With ffield .Name = "contaminant" With .Text...

Comma Style button
How do I use the comma style button on the tool bar? I'd like to make 32759 look like 32,759 without adding in the comma and copy the formula to the rest of the column of numbers. I selected the cell I'd like to change, by using the mouse, then selected the comma button on the tool bar and received ##### as the answer. If you could send back a reply, I'd appreciate it. thanks so much. Lisa, Making the column bigger might help with that. This (#####) is Excel's way of telling you the data is too big to be displayed in the current column. Chris "Lisa" <naut...

Tab seq dynamically...
I have a button which added dynamically to a property sheet. Now for setting the tab sequence with this new button, Am using SetWindowPos() method. Now tab sequence is proper. THE PROBLEM IS Through the arrow keys, I could not navigate to the last button for which I called SetWindowPos. where as through tab keys I could go to the last control. I will appreciate ur help in this. DETAILED DESCRIPTION I have three buttons (OK,Cancel, Help)on the property sheet. I added a button "Default" to the property sheet and positioned between Cancel and Help. I set the tab sequence as ...

SharePoint Alternate Access Mapping to my Dynamics GP BP site
Hello, If I have posted this question in the wrong forum please let me know! I’m looking for some guidance on changing the Alternate Access Mapping for my Dynamics Business Portal site. So I can implement Single Sign On via ISA Server which is supported on one web listener. Present configuration: Default Zone: http://geneva:222 I would like to add: Internet Zone: http://dynamicsbp.proclub.com I presently have another SharePoint Collection (The Main Portal) http://geneva configured which listens on Port: 80. I tried to add the Alternate Access Mapping http://dynamicsbp.proclub.com...

PropertyPage Buttons
I have a 3-page PropertyPage using CPropertySheet & CPropertyPage (as usual). My buttons are not what I expected. The code below is what I have on page2 (which is derived form CPropertyPage). I have commented out code just for referenced. This gives me 4-buttons: Back, Next, Cancel, Help. From the code below, I should only get the Back & Next button. BOOL CPage2::OnSetActive() { CPropertySheet* parent = (CPropertySheet*)GetParent(); parent->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT); /* A set of flags that customize the function and appearance of the wiza...

dynamic charting #2
Hi I have to update a weekly spreadsheet With week numbers in column B x series and three y series percentages in G,H,I columns. Could someone please help I need these to update automatically. If someone can explain in detail I would appreciate 39 2097 2165 68 1770.7 97 96.86 118.43 40 2443.15 2201 -242.15 1548.93 97 111.00 157.73 41 2162.83 2259 96.17 1600.78 97 95.74 135.11 42 2163.08 2241 77.92 1545.1 97 96.52 140.00 43 2137.5 2271 133.5 1664.6 97 94.12 128.41 44 2160.67 2298 137.33 1455 97 94.02 148.50 Ta Brian ...

Changing user account / Domain Logon Name
We are in the process of changing domains from A to B. How can I change the user domain account in CRM from DomainA\JDoe to be DomainB\Jdoe -- David Carroll MCSE, DBA Not sure exactly what you are trying to do, but it sounds like it may not be that simple. If you are truly changing your domain, you may also break the ties to AD that are stored in the DB. If you are adventerous, you could try by editing the SystemUserBase table. However, I would think using the Redeployment tool would be a safer approach. Matt Parks MVP - Microsoft CRM ---------------------------------------- -----------...

Button Control Wizard Error
When I select the Form Operations in the wizard I get Invalid use of null and no actions in right pane. In the combo box wizard i get mouse up errors among others. How do I repair my wizards? Thanks If this happens on a fresh, empty db then a re-install or a repair install is in order. Tim Reid wrote: >When I select the Form Operations in the wizard I get Invalid use of null and >no actions in right pane. In the combo box wizard i get mouse up errors >among others. How do I repair my wizards? Thanks -- HTH - RuralGuy (RG for short) acXP WinXP Pro Please post back to this...

Button disable
Hi I have a button which runs a macro which dose the month end stuff. How can I prevent the operator from pressing it a second time in a session. Thanks Charles Maybe you could create a log worksheet (hide it if you want). Then plop in the year/month in one of the cells after your code does what it needs to do. But change the beginning of the code to check for that value first. If the code finds it, a little error/warning message and dump them out (or let them override it???). I created a worksheet named Log. I put "Year/Month" in A1 I put "UserName" in B1 I put &...

Need a method to Dynamicly change the X axis Scale on a chart. #2
I dynamically change the amount of data on a chart. This causes the X axis Scale to either to either show too few values or too many values ( a solid black line if too many). I would like a method to dynamically change the scale values in relation to the data span. Joe - Do you want to limit the number of points displayed? http://peltiertech.com/Excel/Charts/Dynamics.html http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=246 Or do you want to link the axis scales to something you calculate in the sheet? http://peltiertech.com/Excel/Zips/SwitchXYAxes.zip - Jon ----...

Dynamically populate a drop down list
Hi, I'm trying to dynamically populate a drop down list in MS CRM (1.2) based on certain parameters. I suppose I could do it using a SQL stored procedure, but I would prefer to use standard/supported CRM customizations. Any assistance in this would be greatly appreciated. Thanks! -Dave- Dave, You can do it in 3.0 pretty easily based upon an example in the SDK... Here are some pretty pictures... http://blogs.msdn.com/midatlanticcrm/archive/2005/12/04/499868.aspx I have not tried it with 1.2, but it could probably work... Thanks Ben "Dave" <renor321@yahoo.com> wrot...

CRM Integration with MBS/Dynamics products
Hi, Anyone know anything about the integration between CRM 3.0 and ...say.... Dynamix AX/Axapta? I'm thinking sharing of customer data and such.... Jeppe Jespersen Denmark There is nothing available yet. You would need to build it. -- Matt Parks MVP - Microsoft CRM "Jeppe Jespersen" <jdj curly jdj dot dk> wrote in message news:OAfVImWLGHA.3276@TK2MSFTNGP09.phx.gbl... Hi, Anyone know anything about the integration between CRM 3.0 and ...say.... Dynamix AX/Axapta? I'm thinking sharing of customer data and such.... Jeppe Jespersen Denmark ...

Dynamics GP 10 and Dynamics AX 4.0
just a half year ago, our company has started to work with Dynamics AX 4.0. Now i am doing some programming in X++ and almost customizing reports. Accidently, i stumpled on Dynamics GP 10.0 and i am wondering what s the difference between AX and GP? What stands GP for? Maybe GP is to replace AX, and our company backs to wrong horse? Does GP 10 contains AX 4.0? I have learnt lot of X++ programming, would it be possible to using X++ in the GT 10 field, too? Great Plains (GP) is another ERP system that Microsoft acquired a few years ago when it acquired the company of the same name. GP ...

How to access a category name and code from vbscript
I am modifying the lineitem.html for the status bar in Store operation. I want to ask how can i access the category name and code for each item, i only can find a categoryid function, which is in the TransactionEntry.Item.CategoryID, but can not access the name and code for the category Raemond, You will need to retrieve the name and code via SQL using the ID: resultSet=QSRules.OpenRecordset("SELECT Name, Code FROM Category WHERE ID=" & TransactionEntry.Item.CategoryID, true) - Evan Culver New West Technologies Raemond wrote: > I am modifying the lineitem.html for t...

Need Graphic For Button
Group, I am looking for a source for a graphic to use on a button. I would like to find a small red checkmark that I can put on a small button. Does anyone know of a source where I can find one? I am willing to pay for it if there isn't a free one available. Thanks so much, BobV Bob, A neat trick I've used for years is to use text. In the button caption... hold the Alt key and type 0052 on the num pad Change the font for the button to Dixieland. This will give you a checkmark on your button. Use the font size to adjust, and color to suit...

How can I alphabetize re-named tabs on Excel?
How can I alphabetize re-named tabs on Excel? hi see this site... http://www.cpearson.com/excel/sortws.aspx regards FSt1 "Wil" wrote: > How can I alphabetize re-named tabs on Excel? ...

will not eval a function name from a table.
Hello, I have a table of reports and the functions that must run before the report is opened. Set db = DBEngine(0)(0) sSQL = "SELECT DISTINCTROW tblReportSelect.CompanyID, " & _ "tblReports.ReportID, tblReports.ReportName, " & _ "tblReports.ActualName, tblReports.FuncName " & _ "FROM tblReportSelect INNER JOIN tblReports ON " & _ "tblReportSelect.ReportID = tblReports.ReportID " & _ "WHERE (((tblReportSelect.CompanyID)=" & [Forms]!...

Defined names and calculation speed
I noticed this statement on .... http://www.decisionmodels.com/calcsecrets.htmdefined "....defined Names are recalculated each time a formula that directly refers to the name is recalculated" It seems that giving a range a defined name can slow down calculation. I realise that naming ranges makes it easier to understand formulas, but do they really slow down calculations? Rob Hi Rob, Using defined names makes Excel do extra work, so yes they do slow Excel down a small amount, but generally you will not notice the effect unless you have names that contain very time-expensive fo...