+ Reply to Thread
Results 1 to 2 of 2

Clearing Combo Boxes in User Form then setting data range for new submission

  1. #1
    Registered User
    Join Date
    11-21-2022
    Location
    United Kingdom
    MS-Off Ver
    365
    Posts
    2

    Clearing Combo Boxes in User Form then setting data range for new submission

    Hi. I am trying to use a sub routine called Reset which clears all controls and then sets the data range for each combo box ready for a new submission.

    The Intention is to clear all text in each control including the combo boxes, but if a combo box, reassign the range that the combo box needs to display as options for next input. I can use. Clear if my options are coded as add.Item but not when I select the range the combo box ctrl needs to source the data from. I have multiple combo boxes in my userform. The .txt*Value all seem to reset OK

    Here is the VBA code:

    Sub Reset()

    Dim iRow As Long

    iRow = [countA(Database!A:A)]

    With frmForm

    .txtReqID.Value = "" 'clears the .txtReqID

    .cmbBrand.Clear 'Clears data from the Brand Combo Box (but doesn't work)
    shSettings.Range("D2", shSettings.Range("D" & Application.Rows.Count).End(xlUp)).Name = "Brand" ' assigns dynamic range for the combo box "Brand"
    .cmbBrand.RowSource = "Brand"
    .cmbBrand.Value = "" 'set the value t show in combo box after reset

    .cmbRP.Clear
    shSettings.Range("A2", shSettings.Range("A" & Application.Rows.Count).End(xlUp)).Name = "RP"
    .cmbRP.RowSource = "RP"
    .cmbRP.Value = ""

    .cmbBF.Clear
    shSettings.Range("K2", shSettings.Range("K" & Application.Rows.Count).End(xlUp)).Name = "BF"
    .cmbBF.RowSource = "BF"
    .cmbBF.Value = ""

    .cmbLocation.Clear
    shSettings.Range("I2", shSettings.Range("I" & Application.Rows.Count).End(xlUp)).Name = "Loc"
    .cmbLocation.RowSource = "Loc"
    .cmbLocation.Value = ""

    .txtRole.Value = ""
    .txtSalary.Value = ""

    I have seen that you could use NUll but not show how to write that? Any help greatly appreciated.
    Last edited by BleuStessia; 11-23-2022 at 01:03 PM. Reason: Solved

  2. #2
    Registered User
    Join Date
    11-21-2022
    Location
    United Kingdom
    MS-Off Ver
    365
    Posts
    2

    Re: Clearing Combo Boxes in User Form then setting data range for new submission

    Solved:

    I changed the code for each combo box to:

    .cmbLocation.Value = ""
    shSettings.Range("I2", shSettings.Range("I" & Application.Rows.Count).End(xlUp)).Name = "Loc"
    .cmbLocation.RowSource = "Loc"


    and this resolved the issue - no need to use .Clear

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Populate text boxes on user form, from combo box on same user form
    By Richardswaim in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 07-03-2016, 09:35 AM
  2. [SOLVED] Setting All Form Control Combo Boxes To A Specified Value
    By andrewryan920 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2014, 03:22 PM
  3. populating list boxes and combo boxes in a user form.
    By ahceinaej in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2014, 11:54 AM
  4. combo box user form code for two combo boxes
    By robert.begley1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-01-2012, 02:25 PM
  5. [SOLVED] Clearing a Combo Box then trying to submit user form to Workbook gives error messages
    By colvinb in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-21-2012, 02:18 PM
  6. Replies: 5
    Last Post: 05-09-2012, 08:10 AM
  7. [SOLVED] Excel User form with 4 Combo Boxes
    By ca1358 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-16-2006, 03:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1