title: Excel VBA Userform.Name as Variable to next Modul in case of Button Click
body: <p>i really need some help, im new to VBA programming and just learn all by myself. 
  Thx for all Help.</p>
  
  <p><strong>What is my problem ?</strong></p>
  
  <p>I have more than 1 Userforms in my Tool and every Userform contains alot of Buttons some Buttons the same on other Userforms and some different. 
  if i click a button in a Userform, the class cant give my userform.name as a variable to the next module.</p>
  
  <p>in the Code "Class" sUserform is alltime "nothing"</p>
  
  <p><strong>My Code
  Userform</strong></p>
  
  <pre><code>Option Explicit
  Private myBtn As clsCMD
  
  Private Sub UserForm_Activate()
  modUI.ufGETICON Me
  End Sub
  
  Private Sub UserForm_Initialize()
  
  modMSG.ufINFO
  modAUTOOPEN.Workbook_Open Me
  
  Dim ctrl As Control
  
      For Each ctrl In frmMain.Controls
          If TypeOf ctrl Is MSForms.CommandButton Then
              Set myBtn = New clsCMD
              Set myBtn.Button = ctrl
          End If
      Next
  End Sub
  </code></pre>
  
  <p><strong>Class</strong></p>
  
  <pre><code>Option Explicit
  Public WithEvents Button As MSForms.CommandButton
  
  Private Sub Class_Initialize()
      Static collButton As New Collection
      collButton.Add Me
  End Sub
  
  Private Sub Button_Click()
  
  Dim sButton As String
  
  sButton = Button.Name
  CMDTEST *sUserform*, Button
  
  End Sub
  Private Sub CMDTEST(*sUserform As Object*, sButton As Object)
  
  
  
  If sButton.Name = "cmd_Admin" Then
      modCMD.cmd_Admin
  End If
  If sButton.Name = "cmd_OItem" Then
      modCMD.cmd_OItem sUserform
  End If
  
  End Sub
  </code></pre>
  
  <p><strong>Modul</strong></p>
  
  <pre><code>Option Explicit
  Public sUserform As Object
  
  Public Sub cmd_Admin()
  Dim sAnswer As String
  
  sAnswer = InputBox("Passwort f?r den Zugang zum Adminbereich eingeben:", "Zugang Adminbereich")
  
  If sAnswer = sPASS Then
      Unload frmMain
      frmMain.Hide
  
  ElseIf sAnswer = "" Then
      Exit Sub
  Else
      MsgBox "Inkorrektes Passwort eingegeben", vbInformation + vbOKOnly, "Passwortabfrage negativ"
  End If
  Application.Visible = True
  
  End Sub
  
  Public Sub cmd_OItem(sUseform As Object)
  
  sUserform.Hide
  
  frmOnIt.Show
  
  End Sub
  </code></pre>