Macro must return the name of the button

Hi there,

I want to a macro to display the name of the button (or object) from where I 
am calling that macro. Anyone an idea?

Brussels (1)
5/17/2006 8:10:02 AM
excel 39879 articles. 2 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 6

What sort of button (userform, worksheet forms, worksheet control toolbox)?


Bob Phillips

(remove xxx from email address if mailing direct)

"Derek Brussels" <Derek> wrote in message
> Hi there,
> I want to a macro to display the name of the button (or object) from where
> am calling that macro. Anyone an idea?
> thanks,
> Derek

5/17/2006 9:36:15 AM
Derek Brussels wrote:
> I want to a macro to display the name of the button (or object) from where I
> am calling that macro. Anyone an idea?

Why do you need this? Don't you know what button  you
have attached the code to?

If you are trying to have the same code attached to different
buttons, and still have it do different work for different buttons,
then you have to put a layer between. Like so.

Button1 -> Sub1 -> MainSub
Button2 -> Sub2 -> MainSub
ButtonN -> SubN -> MainSub

So, each of these small functions is attached to only one button,
knows what button it is attached to, and picks out the args to
call MainSub with so it does the right work.

puppet_sock (108)
5/17/2006 3:41:58 PM
If the button or control is from the Forms command bar (not the 
Controls command bar) you can use Application.Caller to get the 
name of the control.

Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC

"Derek Brussels" <Derek> wrote 
in message
> Hi there,
> I want to a macro to display the name of the button (or object) 
> from where I
> am calling that macro. Anyone an idea?
> thanks,
> Derek 

chip1 (1821)
5/17/2006 10:22:37 PM

Similar Artilces:

When I query a datatable using VLOOKUP I get the answer returned fro the first instance of a name that appears albeit in the correct column If ABC is in row 2 with a value of 5 and also in row 3 with a value o 6, I get the reult 5 from row 2 in my formula. What I need is for formula that will sum all instances of the row name ABC so giving m the answer 11 (5+6). Ideally I don't want to go into VB scripting bu can handle nesting ormulae. I don't want to use dat>subtotals either a I need it to work 'behind the scenes' I am using Excel 2000. Any help would be gratefully receiv...

Return Reciepts
Is there a way to control return Reciepts by reciepiant? I want to recieve return reciepts, but I have several people that I do not need to get them from.... I am using OL 2002 Thanks Bruce ...

Outlook Name Suggestion Issue
I am working on a strange issue with name suggestion in Outlook 2k3 version. For some users when I type the alias for the first time it resolved the name. The next time I try to type few characters for the same user. it suggests me with the complete name but this time in the brackets <> the alias would be some starnge name with some numbers. This strange alias number does not existing in our organization nor the number that appears along with it appears in the User AD properties. Examples: First time I type the alias as: "nnair" and press Ctrl + K = It resolves...

Where do I find the commands for a macro
I recorded a macro to input a number, move right 3 spaces, enter a number, ect ....... when I recorded it I intended to go back and replace the numbers I put in to record with whatever I need like a question mark. Here is the macro as it is now: Sub Macro1() ' ' Macro1 Macro ' ' Keyboard Shortcut: Ctrl+a ' ActiveCell.FormulaR1C1 = "123" Range("E64").Select ActiveCell.FormulaR1C1 = "123" Range("H64").Select ActiveCell.FormulaR1C1 = "123" Range("K64").Select ActiveCell.FormulaR1C1 = &q...

Enable/Disable Macros
I'm having a very strange problem in Excel. Every so often, when I open a file (not always the same file), I get the error "Macros are disabled, etc.....", but they aren't disabled, and they never were. It happens perhaps once a week, and I have to shut down excel and re-open it to avoid getting that message again. I don't even have to play around with the Security Level (which is always set at Medium). Has anyone else had this problem? Or does anyone know what might cause this message to come up if the settings are fine? Thanks, Moe -- Moe ----------------------...

Sql to return items in promo
Hi, Somone much more inteligent than me once told me a sql to run in HQ which would return all items which have a Qty discount/ promotion applied to them.. I cant find it - would someone be able to remind me? Thanks v much Phil Hi Philip see if this returns what you are looking for.... select i.itemlookupcode, i.description, qd.description from item i inner join quantitydiscount qd on i.quantitydiscountid = "Philip Gass" wrote: > Hi, > > Somone much more inteligent than me once told me a sql to run in HQ which > would return all items which have a Qt...

Send/Receive button has failed
Neither the send/receive button on the standard toolbar nor the F5 button are working. However, I can get email by going to tools-->send/received-->2 All Accounts. Can anyone tell me how to get the these buttons to work again? Tod ...

Different Button Position When On Design Screen and Application Ru
I use MFC Visual C++ 4.2. I am customizing an application. The existing application has already got buttons, CListView, etc. I just add a button next to other button. There are 4 buttons in a row. I've placed it in a good order following the existing buttons, but when I ran the app, the position changed. The button I'VE JUST CREATED moved from its position. Why it can be happen? How to solve this? Thank you. Will your application compile and build with the latest free version of Visual Studio? You might try that, since your version of vc++ is dated. "Landon" ...

i want to only select one name from a list of the same names
I have a column of names and in the column there are 20 rows saying "apples" and 10 rows saying "oranges" and 5 rows of "bannanas". I would like to produce a report that pulls only the name i.e. "apples", which would then allow me to produce a consolidated list of names. This would mean that I would end up with 3 rows one saying "apples", one saying "oranges and one saying "bannanas". In B1 use =A1 In B2, add =IF(ISERROR(MATCH(0,COUNTIF(B$1:B1,$A$1:$A$20&""),0)),"", INDEX(IF(ISBLANK($A$1:$A$20),&qu...

Question: Macro overloading, passing variable number of arguments
Excel-97 (SR-2) In general I would like to write macros that can be overloaded, for example Hyperlink() has an optional displaytext field. HyperLink( Filename) HyperLink( Filename, DisplayText) Please could someone post a short, useful macro that does such a thing, rather than give a description of how to do so. I have searched the online help for "overloading" and "arguments" but nothing useful is shown there. TIA, Fred. See the help for Functions You are just talking about optional arguments. Function MyFunc(MyStr As String, Optional MyArg1 As _ Integer = 5, _ ...

Applying Filter to Form in a Looping Macro Causes Catastrophic Err
I have a form that contains order details and I run through a loop that applies a filter to the form (only view one order at a time), and then removes the filter, applies a different filter (next order) and then removes it etc. After about 300 times, I get a message stating "not enough memory..." This is fairly consistent and have narrowed it down to being a MS Access issue (as opposed to a hardware issue). I have reduced the number of times the looping macro runs to 100, and finishes successfully (without the memory error), but renders the keyboard useless for changing an...

Macro #7
Hi, I have a bunch of documents that are .csv in excel. WHat I am doing is opening each, deleteing a bunch of colums, autowidth and then saving the file in another folder as an .xls file. I have everything working but the filename. I cannot figure out how to do the following: 1, save the file as an excel file I.E. the filename is test.csv, I want the macro to be able to save it as test.xls And when I open the next file called test2.csv I want it to save as test2.xls. Right now it asks me if I want to overwrite whats there because it is trying to save everything as test.xls. Hope ...

to Make Labels with different photo and name
I probably will want the size of an 8 label page but they will have a different photo and name on each. Is this possible in Publisher 2002 SP3? Word 2002? Works 2000? I've been all over the net looking for some info to no avail. aaarrrrgh. I did make one label in Publisher and I like the looks of it but for the life of me I cannot find out how to get different ones on one sheet to print. Why can't it be as easy as dragging them? I'll make them individually instead of a mail merge. lol Thanks for any input. AnnE AnnE wrote: > I did make one label i...

Display name change
My problem is this: I need email for just a few users to show up as shown below. This should be seen in the "From:" field on the recipient's email client. John Doe (Contractor) <> Currently it shows up in the recipient mailbox as: John Doe <> I tried changing the display name but it doesn't seem to work any differently. Is this possible? Seems like it should be relatively easy, but I guess I'm missing something somewhere. Dave display name is in fact the attribute you need to change. Once you change it, it should show u...

how do i arrange list of names alphabetically in excel?
see i am arranging a data containing around 100 names of companies.. I dont have them in alphabetical order. i want them in that order. so i just want to know is there any function by which the list of companies would get arrange in an alphabetical order? Try from the Menu bar Data >> Sort >> Ascending -- Hope this help Pls click the Yes button below if this post provide the answer you asked cheers, francis "ganna pritesh" <ganna> wrote in message > see i am a...

command button to open 1 of 2 forms
Hi All, I have 3 forms "DailyRoute", "ServiceCall" and "Installation". "ServiceCall" and "Installation" have control source as "TblCustomers" when the customer details are entered a checkbox is check to identify a Service Call, the issue is that different information is required for each job type ("ServiceCall" or "Installation") therefore I require 2 forms for closing the days work. Is it possible to click the "update" command button in "DailyRoute" and display either "Ser...

How to Enable Macros
A fellow employee was prompted to disabled her macros and unknowingly disabled them. She would like to know how to enable them again. More specifically, she cannot create a new Email message. When she tries this a window pops up stating macros are disabled. Thanks .. try tools/macros/security "Steven" <> wrote in message news:0ae701c4967b$5aede360$a401280a@phx.gbl... > A fellow employee was prompted to disabled her macros and > unknowingly disabled them. She would like to know how to > enable them again. > More specifical...

Chart, Series
I'm not sure if what I am trying to do is possible. I have a chart set up as a series for 2005 and 2006. The legend shows 2005 & 2006. I would like to incorporate a cell reference in the legend field, but have been unsuccessful. For the first series it shows "2005" in the name box. I would like it to include the text "2005" but also add a cell reference, i.e. "2005 - " & mysheet!G4. My hope is that the legend would then display, 2005 - 12,345. Can this be done? If yes, how? I have tried various formula combinations to do it, but no luck. ...

macro help #16
I have the following macro written: Sub SaveFile() Dim newFileName As String Dim curMonthName As String Dim curYear As String Dim curCenter As String Dim curCounty As String curMonthName = MonthName(month(Range("C4"))) curYear = Year(Range("C4")) curCenter = Range("E1") curCounty = Range("C1") newFileName = curMonthName & " " & curYear & " " & curCounty & " Billing CT" & curCenter ActiveWorkbook.SaveAs Filename:= _ newFileName, FileFormat:= _ xlNormal, Password:="", WriteResPassword:=&...

Macro for Company field in CRM Outlook Client
I feel like I'm beating a dead horse but I have to make this work for this implementation; getting the company field in outlook to populate with the Parent Customer information from CRM. This is discussed in detail in this older post: I can't use the suggested custom field addition because it doesn't link to Palms. With several guys out on the field, the macro seems like the only viable option. So the macro I...

Excel Macro at Startup #2
Jason, Thanks for the info. I'll try your excel tip today. Eddie Oah -- eddieh ----------------------------------------------------------------------- eddiehk's Profile: View this thread: ...

formating macro
Hi, I have problem in macro codes. I have recorded macro for rows formatting. For recording a macro I have chosen line no.22. After recording a macro I want to run this in line different rows, say for example line no. 50. But whenever I run this It will go to line no.22 and formatting. How to change macro codes….I don’t want to give particular cell number in macro codes. I want to run this in different cells every time. Please advise me…? Regards, Vishu As always, post YOUR coding efforts for comments. -- Don Guillett SalesAid Software "vishu" <vishu@dis...

Name Conflict Dialog Box???
Excel 2000 ... I have a WorkBook that when I try to copy one of the TabSheets (any of the 3 TabSheets) I get a Pop- up containing the following (very annoying) message. ********************************************************** "A formula or sheet you want to move or copy contains the name 'My_Name' which already exsist on the destination worksheet. Do you want to use this version of the name? To use the name as defined in the destination sheet, Click Yes. To rename the range referred to in the formula or worksheet, Click No, and enter a new name in the Name Conflict Di...

Add-in must be 'run' one time to stick? How to auto invoke?
Thanks to Dave Peterson's recent sample and tips to get started I have gotten past the notion of a script-holding template file and gotten all the functionality I need into a .xla addin menu The functions in the addin are made available thru a toolbar menu created like... Set cbcCutomMenu = _ cbMainMenuBar.Controls.Add(Type:=msoControlPopup, _ Before:=iHelpMenu) '(5)Give the control a caption cbcCutomMenu.Caption = "M&y Menu" .... and added by these subs in the 'View Code' thingy: Private Sub Workbook_Activate() Run "...

Sheet change event to return sheet name just left
Does anyone have any idea how I can get the name of a worksheet that I have just moved from. So if I am in Sheet1 and move to Sheet2, how do I get a macro to return Sheet1. In all the Events I have looked at they all return the name of the sheet that I have moved to not the sheet I have left. Any help will be gratefully received -- with kind regards Spike We need to remember it. In a standard module: Public OldSheet As String Public NewSheet As String In the worksheet code area of every sheet: Private Sub Worksheet_Activate() If IsEmpty(OldSheet) Then OldShe...