Close Window   
Free Ebook
Got an Excel Question?
Ask it in our Excel forum!
Subscribe for Free Excel tips & more!

Unwanted Code

Forum Register
Search Excel Forum Posts, Tutorials, Macros, Tips, and More

Each time I open Excel and press [Alt] [F11] in a blank workbook, I have the following code:

'Entry point for RibbonX button click
Sub ShowATPDialog(control As IRibbonControl)
    Application.Run ("fDialog")
End Sub

'Callback for RibbonX button label
Sub GetATPLabel(control As IRibbonControl, ByRef label)
    label = ThisWorkbook.Sheets("RES").Range("A10").Value
End Sub

How can I permanently delete this?
Thank you

View Answers     

Similar Excel Tutorials

Quickly Copy Cell Formatting to Other Cells in Excel
How to copy all of the formatting of a single cell to other cells in the spreadsheet without having to re-apply eac ...
VBA Comparison Operators
VBA comparison operators are used to compare values in VBA and Macros for Excel. List of VBA Comparison Operators ...
Get the Name of a Worksheet in Macros VBA in Excel
How to get the name of a worksheet in Excel using VBA and Macros and also how to store that name in a variable for ...
Pause a Macro or Make it Slow Down in Excel
How to make a macro stop or pause for a specified amount of time. This allows you to slow down the execution of a m ...

Helpful Excel Macros

Excel Macro to Save a Specific Worksheet as a New File
- This Excel Macro allows you to save a specific worksheet within the Excel Workbook to its own new file. You will be a
Macro to add a New Line to Message Box Pop-up Windows in Excel
- This is a very simple Message Box, pop-up window, macro for Excel that illustrates how to put new lines, the same thi
Save the Current Worksheet as a New Excel Workbook File
- This Excel Macro will save the currently visible/active worksheet (the one that you see when you run the macro) to a
Excel Macro that Searches Entire Workbook and Returns All Matches
- This is the ultimate Lookup Macro for Excel. It will search every worksheet in the workbook and return all of the mat
Complete Guide to Printing in Excel Macros - PrintOut Method in Excel
- This free Excel macro illustrates all of the possible parameters and arguments that you can include in the PrintOut Meth

Similar Topics


I opened excel this morning to discover 2 files in the VBA editor that I've not seen before. One is called FUNCRES.XLAM with the following code in a module


'Entry point for RibbonX button click
Sub ShowATPDialog(control As IRibbonControl)
    Application.Run ("fDialog")
End Sub
'Callback for RibbonX button label
Sub GetATPLabel(control As IRibbonControl, ByRef label)
    label = ThisWorkbook.Sheets("RES").Range("A10").Value
End Sub

The other is ATPVBAEN.XLAM which when I try to open is password protected.

Firstly what is the XLAM part of the file? secondly I didnt create them and no one else has any idea what they are so how could they get there? and thirdly is there any way of deleting them? I cant remove them for some reason. I know this is pretty random but just seeing if anyone else had experienced this type of thing.

Thanks in advance

I have an xlam AddIn which creates a custom tab in Excel. I want to allow users to choose their own keytip for this tab using the getKeytip functionality of Ribbbon XML, e.g.
HTML Code:

XML: <tab id="rbnTestTab" label="Test Tab" getKeytip = "getKeytip">


VBA: Public Sub GetKeytip(control As IRibbonControl, ByRef label)
'get keytip function sets the keytip of a control according to its ID
'take the value stored on the worksheet
label = CStr(wksKeyTip.Range("rngKeytip").Value)
End Sub

I have a macro which gets the user's value from an InputBox, pastes it into a named range on a sheet, and then uses the .Invalidate and .InvalidateControl on the Ribbon object and the control "rbnTestTab" respectively, therefore calling the GetKeytip for the tab and setting the keytip.

This code works fine in Excel 2007, but isn't working at all in Excel 2010, does anyone have any suggestions why not? I can't figure it out and there isn't anything in the usual places (Ron de Bruin's site, Ken Puls' blog, Msdn, here!) mentioning any compatibility issues between Ribbon XML in 2007-2010.

Two additional notes which may help (or further confuse!):
1. The VBA callback is different between 2007-2010 (ByRef argument has different name); changing the argument to be called "returnedVal" stops the code working in 2007, but doesn't make it work in 2010, which is odd!:

VBA: Sub GetKeytip (control As IRibbonControl, ByRef label)
VBA: Sub GetKeytip(control As IRibbonControl, ByRef returnedVal)

2. If you use this code and try to set a keytip which is already assigned, e.g. "H" (Home tab), then the getKeytip fails and you get "Y" or "Y1" as the keytip on your tab, and this then cannot be changed to anything else after that by rerunning the macro/invalidate routines - you have to restart the workbook.

Any help greatly appreciated!

Hi, I've created my gallery where user can choose my color (I need more colors than the themes offers) and I use a label of each item like RGB value.
My question: How can I get label of item in VBA callbacks?

Look at Ribbon's code bellow (I had to put it as image)

and here is my code in VBA


Dim mIRibb  As IRibbonUI
'Callback for customUI.******
Sub idc_LoadRibbon(ribbon As IRibbonUI)
    Set mIRibb = ribbon
End Sub

'Callback for idc_galColor getItemLabel
Sub idc_GetLabel(control As IRibbonControl, index As Integer, ByRef returnedVal)
    MsgBox "Control Id = " & & vbNewLine & _
           "Index      = " & index & vbNewLine & _
           "ReturnVal  = " & returnedVal, vbInformation, "GetItemLabel"
End Sub

'Callback for idc_galColor onAction
Sub idc_Color_Click(control As IRibbonControl, id As String, index As Integer)
    MsgBox "Control Id = " & & vbNewLine & _
           "ID         = " & id & vbNewLine & _
           "Index      = " & index, vbInformation, "OnAction"
End Sub

Because I need to work with number which are stored in label property I'd like to know how Can I get the label property of selected item.
Of course, I don't want to show to user label property - because it is strange for them .

Hello all

Trying to create a simple addin to show my custom tab ..............

Tough addin is loading succesfully without error but not showing my tab.......

Addin has a simple function which is working properly but only not showing tab.....

Heres a XML

HTML Code:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="" >
      <tab id="mrbrave" label = "mrbrave" insertBeforeMso="TabHome">
        <group id="ColorText" label="ColorText">
		<button id = "mrbraveb1" label = "ColorText" size = "large" onAction = "callColorText"/>

and my vba code


sub callColorText(control as iRibbonControl)
activecell.Font.ColorIndex = 4
end sub

function lenof(r as range)
lenof = len(r.value)
end function

please help me out.......


I'm trying to assign a macro to a button within a customized Ribbon. When the following code is copied into a Module within the active Workbook, the button works fine. However, when the same code is copied to a module within Personal.XLSB, I get the following error message in Excel:

"Cannot run the macro 'rxbtnTest_Click'. The macro may not be available in this workbook or all macros may be disabled"

Macro Settings is set to "Enable all macros". Basically, I'd like to use macros saved in Personal.XLSB rather than have to rely on macros saved in the current workbook only.

Here is the text from the UI Editor:

<group id="Navigation"
<button id="rxbtnTest"

VBA Code for Macro "Test"

'Callback for rxbtnTest onAction
Sub rxbtnTest_Click(control As IRibbonControl)
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.NumberFormat = "$#,##0"
End Sub

I have a Excel 2010 workbook that contains a custom ribbon. I have created the appropriate XML code to present the ribbon just as I want. The ribbon has one 'toggleButton' control that shows/hides the formula bar. This control was initially just a 'button' control and worked perfect, but when I made it a 'toggleButton' control i got 'Wrong number of arguments or invalid property assignment error'. I prefer a 'toggleButton' so it will show the stat of the control. My code is below. Can anyone help me diagnose this problem?


 'Callback for ShowHideFormBar onAction
 Sub callackShowHideFormBar(control As IRibbonControl)

'  Sub callackShowHideFormBar(control As IRibbonControl)
    Application.ScreenUpdating = False
    Select Case control.ID
    Case "ShowHideFormBar"
    If Not Application.DisplayFormulaBar Then
      bStateShowHideFormBar = False
    Application.DisplayFormulaBar = True
      bStateShowHideFormBar = True
      Application.DisplayFormulaBar = False
    End If
    myRibbon.InvalidateControl ("ShowHideFormBar")
End Select
End Sub

After several days of searching this site and many others, I Think I'm on my to understanding the basics of creating my own custom ribbon menu. I found the "CustomUIEditor" and Andy Pope's RibbonX Visual Designer. Both great tools.

I've created my menu. It has a new tab, two group, and some controls. My task is to load strings into one of the comboboxes from a list on a sheet. The id of the combobox is cmbo_ReachesCombo. I grabbed some code from Andy Pope's site that changes the text for a editbox. I tried to adapt it to my combobox, but it didn't work. Can anyone help with specific code for loading a combobox on the ribbon?


This is the xml

<        ribbon         >
<        tabs         >
<        tab 
        id        =     "     TSTab     "
     label        =     "     Time Series     "
     tag        =     "     TS     "     >
<        group 
        id        =     "     grpNavigate     "
     imageMso        =     "     UpgradeWorkbook     "
     label        =     "     Navigate     "
     tag        =     "     TS     "     >
<        comboBox 
        id        =     "     cmbo_ReachesCombo     "
     imageMso        =     "     DiagramReverseClassic     "
     label        =     "     Goto Reaches     "
     screentip        =     "     Select a Reach Page to Show     "
     tag        =     "     TS     "
     getText        =     "     cmbo_ReachesCombo_getText     "
     onChange        =     "     cmbo_ReachesCombo_onChange     "     />
<        button 
        id        =     "     btn_FlowSum     "
     imageMso        =     "     ReturnToTaskList     "
     label        =     "     Flow Summary     "
     screentip        =     "     Show the Flow Summary Page     "
     tag        =     "     TS     "
     onAction        =     "     btn_FlowSum_onAction     "     />
<        button 
        id        =     "     btn_SpeciesList     "
     imageMso        =     "     DatasheetNewField     "
     label        =     "     Species List     "
     screentip        =     "     Show the Species List Page     "
     tag        =     "     TS     "
     onAction        =     "     btn_SpeciesList_onAction     "     />

<        group 
        id        =     "     grpOptions     "
     imageMso        =     "     PageBreakInsertOrRemove     "
     label        =     "     Split Screen Options     "
     tag        =     "     TS     "     >
<        comboBox 
        id        =     "     cmbo_OptionList     "
     imageMso        =     "     DatasheetView     "
     label        =     "     Option List     "
     screentip        =     "     Choose an Option to Show     "     />
<        button 
        id        =     "     btn_OptionsOff     "
     imageMso        =     "     ErrorChecking     "
     label        =     "     Turn off Options     "
     screentip        =     "     Turn off     "
     onAction        =     "     btn_OptionsOff_onAction     "     />



    Public Sub cmbo_ReachesCombo_getText(control As IRibbonControl, ByRef returnedVal)
' Code for getText callback. Ribbon control Reaches Combobox
  Dim R As Range
  Set R = Sheets("Options").Range(Range("ReachPagesHeader").Offset(1, 0), Range("ReachPagesHeader").Offset(20, 0).End(xlUp))
    returnedVal = R.text
End Sub    

I set a new toggleButton to Excel ribbon:

Everything else works fine but not the label function.

Sub GetLabel(ByVal control As IRibbonControl, ByRef returnedVal)
       Select Case control.ID
        Case "rxblockmacros"
         If bLabelState Then
          returnedVal = "Activate macros"
          returnedVal = "Block macros"
        End If
      Case Else
     ' do nothing
     End Select

I have tried tons of various ways, but it just doesn't change the text of the toggleButton. When I open that particular document, button will get the label from this function, depending on how I have set bLabelState.

Option Explicit
Public grxIRibbonUI As IRibbonUI
Private bLabelState As Boolean
'Callback for customUI.******
Sub rxIRibbonUI_******(ribbon As IRibbonUI)
      Set grxIRibbonUI = ribbon
      bLabelState = True
End Sub

Any idea what I could try?

I have customized a new tab on the ribbon, incorporating Ron de Bruin's dropdown XML and Vb code and it does work - I can select repeatedly from the dropdown and it takes the user choice and puts in cell B10. The info in B10 is used in a lookup with results in L10. The info in cell L10 is used by another macro that initiates a user form.
Here is the problem - I can continue selecting from the dropdown with no problems UNTIL I run the macro that launches the user form that uses the info in L10. Once I have run that macro/userform I get an error in selecting from the dropdown
Here is the dropdown Vb


Option Explicit

Dim ItemCount As Integer
Dim ListItemsRg As Range
Dim MySelectedItem As String

''=========Drop Down Code =========

''Callback for Dropdown getItemCount.
''Tells Excel how many items in the drop down.
Sub DDItemCount(control As IRibbonControl, ByRef returnedVal)
    With Worksheets("Actual").Range("C15:C121")
        Set ListItemsRg = Range(.Cells(1), .Offset(.Rows.Count).End(xlUp))
        ItemCount = ListItemsRg.Rows.Count
        returnedVal = ItemCount
    End With
End Sub

''Callback for dropdown getItemLabel.
''Called once for each item in drop down.
''If DDItemCount tells Excel there are 10 items in the drop down
''Excel calls this sub 10 times with an increased "index" argument each time.
''We use "index" to know which item to return to Excel.
Sub DDListItem(control As IRibbonControl, index As Integer, ByRef returnedVal)
    returnedVal = ListItemsRg.Cells(index + 1).Value
    ''index is 0-based, our list is 1-based so we add 1.
End Sub

''Drop down change handler.
''Called when a drop down item is selected.
Sub DDOnAction(control As IRibbonControl, ID As String, index As Integer)
' Two ways to set the variable MySelectedItem to the dropdown value

'way 1
    MySelectedItem = ListItemsRg.Cells(index + 1).Value

    ''way 2
    'Call DDListItem(control, index, MySelectedItem)
Worksheets("Actual").Range("B10").Value = MySelectedItem
End Sub

''Returns index of item to display.
Sub DDItemSelectedIndex(control As IRibbonControl, ByRef returnedVal)
    'returnedVal = 0
    MySelectedItem = ListItemsRg.Cells(1).Value

End Sub

''------- End DD Code --------

Here is the "other" macro and userform (I have used ***** in this post to separate)


''Show the variable MySelectedItem (selected item in the dropdown)
''You can use this variable also in other macros
Sub ValueSelectedItem(control As IRibbonControl)
    ' MsgBox "The variable MySelectedItem have the value = " & MySelectedItem & vbNewLine & _
           ' "You can use MySelectedItem in other code now to use the dropdown value"
End Sub

Private Sub UserForm_Initialize()
Me.TextBox1.Text = CStr(ThisWorkbook.Sheets("Actual").Range("L10").Value)
Me.TextBox2.Text = CStr(ThisWorkbook.Sheets("Actual").Range("C11").Value)

End Sub

Private Sub CommandButton1_Click()
End Sub

Private Sub CommandButton2_Click()

End Sub

By no stretch of the imagination am I good at Vb but have got this far
So the error I get is with the change handler for the dropdown
Error 91, Object Variable or With Block Variable not set
I have struggled for a couple of days (and nights) to solve this but am at a loss at to why the dropdown will continue to work after running every other macro but the one that uses related information. Any help would be GREATLY appreciated!
thanks much
PS this is a very large file and doubt I can email or attach

Below is a customUI script. There is a problem with the customGroup2 script. If I delete the code for customGroup2 it works. Where is the mistake? I can't find it.


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<customUI xmlns="">

	<tab id="customTab1" label="Detlef's stuff" insertAfterMso="TabAcrobat">

		<group id="customGroup1" label="Author Analysis stuff" insertAfterMso="GroupEditingExcel">
			<button id="customButton1" label="Find duplicate" size="large" onAction="Duplicate" imageMso="DefaultView" />
			<button id="customButton2" label="XMLtoCSV" size="large" onAction="XMLtoCSV" imageMso="FieldChooser" />
			<button id="customButton3" label="Consolidate" size="large" onAction="Consol" imageMso="ConditionalFormattingHighlightTextContaining" />
			<button id="customButton4" label="Author Analysis" size="large" onAction="AuthorAnalysis" imageMso="WhatIfAnalysisMenu" />

		<group id="customGroup2" label="Other stuff" insertAfterMso="customGroup1">
			<button id="customButton1" label="GetLink" size="large" onAction="GetHyperlink" imageMso="HyperlinkInsert" />



How do I update a label on a custom ribbon from VBA?

I added a label to a custom ribbon where I want to display a date. My model is set to run in a loop for a number of days. As it loops I want the date of the day it is running to be displayed on the custom ribbon. The book I have shows how to add the label control to the ribbon, shows a callback procedure called getLabel1 with the following code:

Please Login or Register  to view this content.

This will then display the system date on the ribbon but how do I go about to display a date of my own on the ribbon from within my loop in VBA? I don't know what to pass as parameters to the sub.

And can I add a icon of a calendar above the date well?


A macro called from my custom ribbon is firing twice and does not stop at break points. Even when I simplify the code to just be a msgbox it fires twice. When running code from the vba editor it works fine. This is Excel 2010.

Ribbon Code:
HTML Code:

<customui xmlns="">
            <tab id="customTab" label="Monthly" insertaftermso="Developer">
                <group id="customGroup" label="Montly">
                    <button id="customButton1" label="Create Instructor Summary" size="large" onaction="modUtilities.CreateNewMonthly()">


I have this code that should update textPERC everytime i exit another Textbox...


Sub TextMOTid_exit(ByVal Cancel As MSForms.ReturnBoolean)
Application.Run = percupdate()
End Sub

Sub percupdate()
 'UserFORM Percentage

    With textPERC
        'Set the text of the label.
             textPERC.Caption = Format(expression:=Sheet1.Range("A3"), Format:="0.00%")
        'Automatically size the label control.
             .AutoSize = True
             .WordWrap = False
        'Set the font used by the Label control.
             .Font.Name = "Tahoma"
    End With
End Sub

However on exit i get the following error...
'Compile Error:
Expected Function or Variable'

Probably something simple!!


I wanted to add a new button with Macro to the existing Excel Ribbon. For this case, I wanted the buttn to be inside the "Formulas" tab and inside the "Calculation" group. Using the Custom UI Editor, I wrote the following:


<customUI xmlns="">

      <tab idMso="TabFormulas" >
        <group id="GroupCalculation" label="Calculation"   >
          <button id="CalculateWB" label="Calculate Workbook" size="normal" onAction="CalcWB" imageMso="AddressBook" />



It doesn't insert the button as I liked it to be or is it not possible to do so?

On my ribbon, I have group that contains a button that opens a Calendar form and a label which will display a date. I want the user to select a date from the calendar which will then in turn update the label with the selected date. However, I'm not sure how to update the label with the user's selected date.

I'm new to Excel VBA and to the RibbonX.

I appreciate anyone's help on how to approach this problem.

So I am trying to call my macro from another macro and ever since i added
control As IRibbonControl i no longer able to called from another macros
Does anyone know how to fix this problem
Thank you for your the help!!

Sub DeleteBlankRows(control As IRibbonControl)
LastRow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Range("G2:G" & LastRow).Select
On Error Resume Next
End Sub

Does anyone know if it is at all possible to figure out in VBA which label is associated with which control? For example, when I create a label by itself on a form, Access asks me if I want to associate that label with a control through a contextual error message. If I select a control, the error is cleared and the controls are "linked" together. Does Access store this link somewhere I can get to programmatically?

Hi All,

I'm trying to work out something that would automatically fill a DYMO label template and print the label. However, I noticed that this is way over my head... So if there is anybody out there who can help... please!

Attached file has a few sheets.
Sheet "WARR_FILL_IN" only contains fixed info which is transferred onto the label.
Sheet "Part" is the sheet where partnumbers and serialnumbers etc are scanned.
Sheet "DYMO label" contains the DYMO label layout (A1:E4) and some calculation explanations (G1:L3).

What needs to happen:
1. People are scanning partnumbers and serialnumbers in the "Part" sheet.
2. When there are 60 scans (column C), the box is full and a DYMO label should be printed for this box.
3. Scanning continues and when another 60 scans are done, the 2nd label should be printed (can be different partnumber).
4. A re-print option for a label should be possible via a re-print button

On the "DYMO label" sheet, I've explained where the data is coming from and also how the 2nd label should look like, based on the scanned examples in the "Part" sheet.
The DYMO printer is a DYMO LabelWriter 400 Turbo.

I'm not even sure if the above is possible in the first place. I would really appreciate it if somebody is able to shine some light on this, as I'm completely stuck...

In case of any questions, please do let me know.

DYMO file.xlsm
Thanks as always!


I am having a problem where the screenupdating = false statement is not working. I have multiple command buttons in a sheet that start and finish with screenupdating false and true, calling all other macros in between. No other macros in the project use this application, and yet it seems to be resetting to true somehow!! This fault is only apparent on one of the commands, all the others work fine and are set up in exactly the same way.

Is there any instance where this application is reset?

The direct code from the command button is below. There are way too many part in between to post, but none of them use screenupdating.



Sub RunCMD_Sale()
On Error GoTo Reset:
Application.ScreenUpdating = False

    If ThisWorkbook.Name = "ZAD Valuation Schedule Master.xls" Then
    MsgBox "This control is not active on the Master Schedule. Please press the 'Control Sheet' button."
    GoTo Reset:
        If ThisWorkbook.Sheets("Instruction").Range("Ref_Schedule_Type") = "FINAL SCHEDULE" Then
        Run "Delete_Property"
        MsgBox "This control can only be activated from the Final Schedule"
        GoTo Reset:
        End If
    End If

Run "UnSelect"
Application.ScreenUpdating = True
End Sub

I use macros to navigate within spreadsheets based on predefined named locations. I was able to assign these "GoTo" macros to buttons on the Ribbon. I am trying to assign the same macros to a ComboBox, but I can't figure out how to do it. Here's the button macro that works fine.

<button id="rxbtnGoTo_Historicals"

Here's my attempt at assigning the same macro to a ComboBox. However, when I try to validate it, I get this error message: "onChange attribute is not declared".

<comboBox id = "NavigationDropDown"
label = "Navigation"
onChange = "rxcboNavigationDropDown_Click">
<item id = "rxitemcboGoTo_Historicals"
label = "Hist"
onChange = "rxitemGoTo_Historicals"/>

Can you please tell me what I'm doing wrong or provide some guidance?


I use macros to navigate within spreadsheets based on predefined named locations. I was able to assign these "GoTo" macros to buttons on the Ribbon. I am trying to assign the same macros to a ComboBox, but I can't figure out how to do it. Here's the button macro that works fine.

<button id="rxbtnGoTo_Historicals"

Here's my attempt at assigning the same macro to a ComboBox. However, when I try to validate it, I get this error message: "onChange attribute is not declared".

<comboBox id = "NavigationDropDown"
label = "Navigation"
onChange = "rxcboNavigationDropDown_Click">
<item id = "rxitemcboGoTo_Historicals"
label = "Hist"
onChange = "rxitemGoTo_Historicals"/>

Can you please tell me what I'm doing wrong or provide some guidance?


Hello everybody.

I am dealing with some problems I can't solve (please take in mind that I started reading about access less than a week ago)

The situation:

I have made a simple data form for data entry. The form name is Pet - Form and the related table is Pet. The form consists of 6 tabs with captions


The corresponding objects are


The last control of each page is either a text box or a combo box.

The problems:
1) When the user enters a value on the last control of each page to be redirected to the next (if he enters a value on the control of the last page to be redirected to the first)
2) The first control of the second page is a combo box (object "Α Τύπος Καταστήματος" with label caption "Τύπος Καταστήματος") with a list of two selections

"1 Αποκλειστικά καταστήματα Pet shops"
"2 Μικτό κατάστημα"

with the numbers being stored at the database.

The second control is a text box (object "Αtext Τύπος Καταστήματος" with label caption "Περιγραφή άλλης δραστηριότητας") which should be initialy inactive and get active when "2 Μικτό κατάστημα" is selected.

Please note that maybe I don't use the correct terminology to describe things as am a beginner and, if possible, keep the language in the corresponding level.

Thank you very much in advance.

I also tried the code suggested here ( but I get run tine error '424' object required.


I'm posting on behalf of a friend who is having trouble with Excel
charts. She's using Excel 2003, and the vertical axis label always
gets trimmed off at the right hand edge of the label. For example the
label "Light Years" will become trimmed to "Light Yea" when displayed
and when printed from Excel.

I tried various solutions like attempting to resize the label,
changing font size and weight etc., but I resolved to changing the
label to "Light Years a", such that the "a" bit got trimmed and
left the label looking as desired! Obviously this has problems when my
friend takes her work to a different machine, as the label displays as

Any help would be much appreciated

I'm creating a form with several drop-down list boxes and I want to add a "helper" field for each. I was thinking of a label that would display certain information based on the option selected in the list box.

For example, say my drop-down has choices of A, B and C. If A is selected, I want the text in the label field to read "For option A you need to blah blah blah", likewise the same setup for the remaining choices. If no selection is made, I want the label text to be blank.

I can set the code up the way I want using a select case statement, but don't know where to insert the code. I see a "click" option for the label field, but not for the drop-down and can't find an "on-change" event or similar for the document itself.

Is there another way to do this?

Thanks - Kevin

Good morning gang. I am trying to write a macro that will create a command button on a sheet and assign VBA code to that button. Basically, my original code creates a new sheet. I would like that new sheet to have button on it that will, when clicked, run another macro.

Here's what I have (of course it doesn't work as intended. The button is created, but the label isn't changed nor is the code assigned):


Sheets.Add.Move Befo =Sheets(1)
'more code follows...then>>>
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
        , DisplayAsIcon:=False, Left:=369, Top:=27.75, Width:=106.5, Height:= _
       Selection.Caption = "My Button"
       Selection.OnAction = "ThisWorkbook.MyCode Here"

Any ideas would be greatly appreciated. Thanks in advance!