Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
command button add another command | Excel Discussion (Misc queries) | |||
VB's Command Button vs Form's Command Button | Excel Programming | |||
Command Button vs Form Button | Excel Programming | |||
Command Button vs Control Button | Excel Programming | |||
Command Button vs Form Button | Excel Programming |