Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 20 Procedures one Command button


Newbie question:

Is it possible to have a command button execute a different procedure
based on the Shape in which the Text Box was called to show from. In
other words I have 20 shapes and I want to use a single Text Box and
then have the Command button execute a different code based on the
Rectangle number.

Sub Rectangle1_Click()
txtBoxForm.Show
End Sub


The only thing I need to change is the row number on ws2, if Rectangle2
is used the row number would be 5.


Private Sub cmdSave_Click()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Worksheets("Names List")
Set ws2 = Worksheets("BDS Under Construction")

'check for a comment
If Trim(Me.BdayText.Value) = "" Then
Me.BdayText.SetFocus
MsgBox "OOPS! Try again."
Exit Sub
End If

'copy text to the appropriate cell.
ws1.Cells((ws2.Cells(4, 80)) - 3, 3) = Me.BdayText.Value
End Sub


I’m probably going about this all wrong, so any thoughts are greatly
appreciated.


Matt


--
Flintstone
------------------------------------------------------------------------
Flintstone's Profile: http://www.excelforum.com/member.php...o&userid=15310
View this thread: http://www.excelforum.com/showthread...hreadid=552001

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 20 Procedures one Command button

Hi Matt

Put this into your userform module, on top, before any Sub:

Public SaveRow as Long

now you can do

Sub Rectangle1_Click()
txtBoxForm.SaveRow = 5
txtBoxForm.Show
End Sub

and use this row number variable in the Save code.

Question now is how you decide the number. If each shape has its own
"Rectangle1_Click" kind of code then you must write it into each one of
them. If multiple shapes has the same macro assigned to them then you'll
know which one that's clicked by using

Application.Caller

HTH. Best wishes Harald

"Flintstone" skrev
i melding ...

Newbie question:

Is it possible to have a command button execute a different procedure
based on the Shape in which the Text Box was called to show from. In
other words I have 20 shapes and I want to use a single Text Box and
then have the Command button execute a different code based on the
Rectangle number.

Sub Rectangle1_Click()
txtBoxForm.Show
End Sub


The only thing I need to change is the row number on ws2, if Rectangle2
is used the row number would be 5.


Private Sub cmdSave_Click()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Worksheets("Names List")
Set ws2 = Worksheets("BDS Under Construction")

'check for a comment
If Trim(Me.BdayText.Value) = "" Then
Me.BdayText.SetFocus
MsgBox "OOPS! Try again."
Exit Sub
End If

'copy text to the appropriate cell.
ws1.Cells((ws2.Cells(4, 80)) - 3, 3) = Me.BdayText.Value
End Sub


I'm probably going about this all wrong, so any thoughts are greatly
appreciated.


Matt


--
Flintstone
------------------------------------------------------------------------
Flintstone's Profile:

http://www.excelforum.com/member.php...o&userid=15310
View this thread: http://www.excelforum.com/showthread...hreadid=552001



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
command button add another command Wanna Learn Excel Discussion (Misc queries) 5 December 7th 08 11:42 PM
VB's Command Button vs Form's Command Button Ronald Dodge Excel Programming 3 May 24th 06 02:23 PM
Command Button vs Form Button Bri[_3_] Excel Programming 2 February 3rd 06 08:18 AM
Command Button vs Control Button RGibson Excel Programming 1 October 14th 03 02:24 AM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 12:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"