Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am not a programmer by trade, so plz bear with me.
I have a spreadsheet containing various macro-linked buttons (actually text boxes) that automate the entry of various strings of text into the spreadsheet. Text-Button1 would enter "aaaa," Text-Button2 would enter "bbbb," etc. I want to maintain the current user simplicity of only one click to enter the respective text for that button. Now I have a separate macro routine for each button, but I would like to simply the code without complicating things for the user, so, if it is possible, I would like to assign the same macro routine to each of these buttons and then depending upon which button is pressed, enter the text that is associated with that button. However, I cannot figure out how to store the name of the last-pressed text-button in a variable to use to branch to the respective text strings. This command does not work apparently because the text box is not actually selected when the code is running: xxx = Selection.Name Although I have access to a more recent version of Excel, I would like to maintain compatibility with Excel 7 (Excel for Windows 95). Possible? Plz help! Thx. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try something like
Sub MyMacro() Select Case Application.Caller Case "Text Box 1": ActiveCell.Value = "aaa" Case "Text Box 2": ActiveCell.Value = "bbb" Case "Text Box 3": ActiveCell.Value = "ccc" Case Else: ActiveCell.Value = "zzz" End Select End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "sth" wrote in message om... I am not a programmer by trade, so plz bear with me. I have a spreadsheet containing various macro-linked buttons (actually text boxes) that automate the entry of various strings of text into the spreadsheet. Text-Button1 would enter "aaaa," Text-Button2 would enter "bbbb," etc. I want to maintain the current user simplicity of only one click to enter the respective text for that button. Now I have a separate macro routine for each button, but I would like to simply the code without complicating things for the user, so, if it is possible, I would like to assign the same macro routine to each of these buttons and then depending upon which button is pressed, enter the text that is associated with that button. However, I cannot figure out how to store the name of the last-pressed text-button in a variable to use to branch to the respective text strings. This command does not work apparently because the text box is not actually selected when the code is running: xxx = Selection.Name Although I have access to a more recent version of Excel, I would like to maintain compatibility with Excel 7 (Excel for Windows 95). Possible? Plz help! Thx. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob, Your code worked flawlessly in some trial runs in Excel 7. Thx
much for the assistance! ===== "Bob Phillips" wrote in message ... Try something like Sub MyMacro() Select Case Application.Caller Case "Text Box 1": ActiveCell.Value = "aaa" Case "Text Box 2": ActiveCell.Value = "bbb" Case "Text Box 3": ActiveCell.Value = "ccc" Case Else: ActiveCell.Value = "zzz" End Select End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "sth" wrote in message om... I am not a programmer by trade, so plz bear with me. I have a spreadsheet containing various macro-linked buttons (actually text boxes) that automate the entry of various strings of text into the spreadsheet. Text-Button1 would enter "aaaa," Text-Button2 would enter "bbbb," etc. I want to maintain the current user simplicity of only one click to enter the respective text for that button. Now I have a separate macro routine for each button, but I would like to simply the code without complicating things for the user, so, if it is possible, I would like to assign the same macro routine to each of these buttons and then depending upon which button is pressed, enter the text that is associated with that button. However, I cannot figure out how to store the name of the last-pressed text-button in a variable to use to branch to the respective text strings. This command does not work apparently because the text box is not actually selected when the code is running: xxx = Selection.Name Although I have access to a more recent version of Excel, I would like to maintain compatibility with Excel 7 (Excel for Windows 95). Possible? Plz help! Thx. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel returning an incorrect total | Excel Discussion (Misc queries) | |||
Links in Excel returning #VALUE | Excel Discussion (Misc queries) | |||
My Excel formala is not returning the correct value | Excel Worksheet Functions | |||
Excel Function returning negative 0 | Excel Worksheet Functions | |||
Returning an array in excel | Excel Programming |