Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Note: Pub Vars easiest, but not portable to multiple Modules calling same UserForm. Is this UserForm NEVER/ALWAYS going to be used with this one Module? Or does it have other possible uses?

Basically, don't declare variables in UserForm. Declare them in Module and assign then my directly referencing UserForm Values like so:

Private Sub UserForm_Initialize()
Dim i As Long
 lCol = Get_lCol(ActiveSheet)
  For i = 1 To lCol
   ColumnLetter = Col_Letter(i)
   Me.ComboBox1.AddItem ColumnLetter
End Sub
Private Sub CommandButton1_Click()
End Sub

Sub PassVarFromUserForm()
 Dim ColLetter As String
 ColLetter = ColPicker.ComboBox1.Value
 Unload ColPicker
 Debug.Print ColLetter
End Sub
  • No labels