Excel Useform: How to hide application but have icon in the taskbar

Try placing this code in the userforms code module: Option Explicit ‘API functions Private Declare Function GetWindowLong Lib “user32” _ Alias “GetWindowLongA” _ (ByVal hwnd As Long, _ ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib “user32” _ Alias “SetWindowLongA” _ (ByVal hwnd As Long, _ ByVal nIndex As Long, _ ByVal … Read more

How to filter listbox values based on a Textbox value

I sure hope the following piece of code is what you are looking for. Private Sub Textbox1_Change() Dim i As Long Dim arrList As Variant Me.ListBox1.Clear If TMP.Range(“A” & TMP.Rows.Count).End(xlUp).Row > 1 And Trim(Me.TextBox1.Value) <> vbNullString Then arrList = TMP.Range(“A1:A” & TMP.Range(“A” & TMP.Rows.Count).End(xlUp).Row).Value2 For i = LBound(arrList) To UBound(arrList) If InStr(1, arrList(i, 1), Trim(Me.TextBox1.Value), … Read more

Differences between Excel’s Form Controls & ActiveX Controls

There is [eternal] confusion surrounding the two types of controls available to Excel — exacerbated by the contrasting terminology used by different online sources. This is only a general overview of the differences between Form Controls and ActiveX Controls (based on my old notes that helped me finally figure out the differences!) Visit the included … Read more

Passing variable from Form to Module in VBA

Don’t declare the variable in the userform. Declare it as Public in the module. Public pass As String In the Userform Private Sub CommandButton1_Click() pass = UserForm1.TextBox1 Unload UserForm1 End Sub In the Module Public pass As String Public Sub Login() ‘ ‘~~> Rest of the code ‘ UserForm1.Show driver.findElementByName(“PASSWORD”).SendKeys pass ‘ ‘~~> Rest of … Read more

Are there disadvantages in putting code into Userforms instead of modules?

Disclaimer I wrote the article Victor K linked to. I own that blog, and manage the open-source VBIDE add-in project it’s for. Neither of your alternatives are ideal. Back to basics. To select different filters I have differnt (sic) userforms. Your specifications demand that the user needs to be able to select different filters, and … Read more