Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8653999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:40:39+00:00 2026-06-12T14:40:39+00:00

I have a VBA form with a variety of selection options including drop downs,

  • 0

I have a VBA form with a variety of selection options including drop downs, text fields, checkboxes and radios.

I just wanted to know about the best way to clear all these fields with a button press. A friend of mine has tried to help by emailing me the code below but unfortunately it doesn’t work, I have checked the variable names.

Any advice on how I can improve it?

Thanks in advance.

Private Sub btnReset_Click()

Unload Me
UserForm.Show

End Sub

Here is the other code for the userform.

Dim DeptCode 'Holds department code

Private Sub UserForm_Initialize()

    Dim c_deptCode As Range
    Dim c_deptName As Range
    Dim deptCodes As Variant
    Dim deptNames As Variant

    Dim ws_dept As Worksheet
    Set ws_dept = Worksheets("lookupDept")

    ' Assign each range to an array containing the values
    deptCodes = Choose(1, ws_dept.Range("deptCode"))
    deptNames = Choose(1, ws_dept.Range("deptName"))

    For i = 1 To ws_dept.Range("deptCode").Rows.Count
        ' Create the combined name (code + space + name)
        CombinedName = deptCodes(i, 1) & " - " & deptNames(i, 1)
        cbo_deptCode.AddItem CombinedName
    Next i

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:40:41+00:00Added an answer on June 12, 2026 at 2:40 pm

    I think when it hits the Unload Me line, code execution stops and that’s why it’s not working for you. Here’s a generic event procedure to reset all (most) of the controls on the form.

    Private Sub cmdReset_Click()
    
        Dim ctl As MSForms.Control
    
        For Each ctl In Me.Controls
            Select Case TypeName(ctl)
                Case "TextBox"
                    ctl.Text = ""
                Case "CheckBox", "OptionButton", "ToggleButton"
                    ctl.Value = False
                Case "ComboBox", "ListBox"
                    ctl.ListIndex = -1
            End Select
        Next ctl
    
    End Sub
    

    It doesn’t repopulate the ComboBoxes and ListBoxes, just clears the selection, which is what I assume you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three drop downs in my VBA form ( cbo_fac1 , cbo_fac2 ,
I have a drop down select list in a VBA form I would like
I have Access Form with some Text fields and one Button. Is there any
Suppose I have a few TextBoxes in a VBA form, called Text1,Text2,Text3. I'm looking
I have a form with a few bound fields and a few 'custom made'
I have to fill several comboboxes for my user form in vba but the
I'm new to VBA and Access. I have to create an inventory loan form
I have text-box in some form in access 2007. I am trying to replace
I have an excel form that I created in combination with VBA. In the
I would like to have a complex form that uses various VBA script files.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.