View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 99
Default Capture # of Button pressed to pass to another form

hello,


http://www.cjoint.com/c/FHcwDJybXga

' "Module 1"
'_________________________________________________ ___________
Sub OpenForm()
UserForm1.Show
End Sub
'_________________________________________________ ___________

' "Classe 1"
'_________________________________________________ ___________
Public WithEvents cmdButton As MSForms.commandbutton

Dim cmdButtonName As String

Private Sub cmdButton_Click()
cmdButtonName = Me.cmdButton.Caption
UserForm2.TextBox1 = cmdButtonName
UserForm2.Show
End Sub
'_________________________________________________ ___________

' "UserForm1"
'_________________________________________________ ___________
Dim x() As New Classe1

Private Sub UserForm_Initialize()
Dim a As Integer
For Each c In Me.Controls
If TypeName(c) = "CommandButton" Then
a = a + 1
ReDim Preserve x(1 To a)
Set x(a).cmdButton = c
End If
Next
End Sub
'_________________________________________________ ___________

isabelle

Le 2016-08-02 Ã* 13:23, jlclyde a écrit :
Hello, I have a form that has six buttons on it. I have another form that I
would like to capture the button that was pressed. For instance if Bt1 is
pressed I am hiding current form, opening a different form and putting 1 in a
text box. Any help would be appreciated.