Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
sth sth is offline
external usenet poster
 
Posts: 5
Default Returning last button pushed in Excel 7

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Returning last button pushed in Excel 7

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   Report Post  
Posted to microsoft.public.excel.programming
sth sth is offline
external usenet poster
 
Posts: 5
Default Returning last button pushed in Excel 7

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
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
Excel returning an incorrect total ETC Excel Discussion (Misc queries) 2 February 24th 10 02:44 PM
Links in Excel returning #VALUE Carol@Bell[_2_] Excel Discussion (Misc queries) 0 June 26th 07 07:41 PM
My Excel formala is not returning the correct value boothguy Excel Worksheet Functions 3 April 27th 06 08:56 PM
Excel Function returning negative 0 ibertram Excel Worksheet Functions 3 November 12th 05 02:26 PM
Returning an array in excel mick Excel Programming 2 February 16th 04 04:07 PM


All times are GMT +1. The time now is 06:30 PM.

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"