+ Reply to Thread
Results 1 to 4 of 4

Ribbon for Clearing dropdown

  1. #1
    Registered User
    Join Date
    10-12-2022
    Location
    berlin
    MS-Off Ver
    2010
    Posts
    2

    Ribbon for Clearing dropdown

    Hi,

    I'm a new joiner on VBA and I created now the button to clearing 5 dropdowns.
    For example, I have a dropdown in which you can select 1,2,3,4,5. When I select all value and click Button "Clear". Values of dropdowns should be blank but the list should be maintained.
    Is it possible to implement it?

    My Code is below
    ----------------------------------------------------------------------------------------------------------------------------------------
    Sub Prio1_getItemCount(control As IRibbonControl, ByRef ItemCount)
    Dim WKSstamm As Worksheet
    Dim LZ As Long
    Dim Counter As Long
    Set WKSstamm = tab_kriterium
    LZ = WKSstamm.Cells(WKSstamm.Rows.Count, 1).End(xlUp).Row
    ItemCount = IIf(LZ > 1, LZ - 1, 0)
    End Sub

    Sub Prio1_getItemLabel(control As IRibbonControl, index As Integer, ByRef Label)
    Dim WKSstamm As Worksheet
    Set WKSstamm = tab_kriterium
    Label = WKSstamm.Cells(index + 2, 1).Value
    End Sub

    Sub Prio1_onAction(control As IRibbonControl, id As String, index As Integer)

    Call Priorisierung(tab_kriterium.Cells(index + 2, 1).Value, 1)

    End Sub

    Sub Prio2_getItemCount(control As IRibbonControl, ByRef ItemCount)
    Dim WKSstamm As Worksheet
    Dim LZ As Long
    Dim Counter As Long
    Set WKSstamm = tab_kriterium
    LZ = WKSstamm.Cells(WKSstamm.Rows.Count, 1).End(xlUp).Row
    ItemCount = IIf(LZ > 1, LZ - 1, 0)
    End Sub

    Sub Prio2_getItemLabel(control As IRibbonControl, index As Integer, ByRef Label)
    Dim WKSstamm As Worksheet
    Set WKSstamm = tab_kriterium
    Label = WKSstamm.Cells(index + 2, 1).Value
    End Sub

    Sub Prio2_onAction(control As IRibbonControl, id As String, index As Integer)

    Call Priorisierung(tab_kriterium.Cells(index + 2, 1).Value, 2)

    End Sub

    Sub RibGondelKURZ_Clear_onAction(control As IRibbonControl)
    Call PrioZurueck

    End Sub
    ---------------------------------------------------------------------------------------------------------
    XML

    <group id="grpRibGondelKURZ_4" label="Priorisierung/Aufbau Planen">
    <dropDown id="Prio1"
    label="Prio1:"
    getItemCount="Prio1_getItemCount"
    getItemLabel="Prio1_getItemLabel"
    onAction="Prio1_onAction"/>

    <dropDown id="Prio2"
    label="Prio2:"
    getItemCount="Prio1_getItemCount"
    getItemLabel="Prio1_getItemLabel"
    onAction="Prio2_onAction"/>

    <button id="b_RibGondelKURZ_Priozurueck"
    label="Prio Zur?cksetzen"
    size="large" imageMso="Undo"
    onAction="RibGondelKURZ_Clear_onAction"/>

  2. #2
    Forum Contributor
    Join Date
    08-12-2020
    Location
    Atlanta, Georgia
    MS-Off Ver
    Office 16
    Posts
    241

    Re: Ribbon for Clearing dropdown

    Hi gk, There are 2 ways I can think of to approach this. Your drop down box will have a linked cell. That is what needs to be deleted in order to clear the box. It will not affect the listfillrange link. If you are linked to say, cell a1, in your macro write
    Range("A1").select
    Selection.Clearcontents
    Create as many as you need with each linked cell.
    Another way to approach this is with data validation. You can set up cells by selecting the cells, then in the Data section of the ribbon select Data Validation, Then select Data Validation... Under Allow: choose List. Under Source: put 1,2,3,4,5 then select the Error Alert tab, then uncheck the Show error alert box. Select OK to close. On the form, select one of the cells. You will see a drop down box on the right. Choose that then select a number 1-5. If you later select the cell, you can press delete to empty the cell. The drop down will still have your choices. You can set up a macro that will simply delete the contents of the cells you want to erase if you still want as mentioned above. You can set up one cell and copy/paste it elsewhere.

    Squeaky

  3. #3
    Registered User
    Join Date
    10-12-2022
    Location
    berlin
    MS-Off Ver
    2010
    Posts
    2
    Quote Originally Posted by Squeaky View Post
    Hi gk, There are 2 ways I can think of to approach this. Your drop down box will have a linked cell. That is what needs to be deleted in order to clear the box. It will not affect the listfillrange link. If you are linked to say, cell a1, in your macro write
    Range("A1").select
    Selection.Clearcontents
    Create as many as you need with each linked cell.
    Another way to approach this is with data validation. You can set up cells by selecting the cells, then in the Data section of the ribbon select Data Validation, Then select Data Validation... Under Allow: choose List. Under Source: put 1,2,3,4,5 then select the Error Alert tab, then uncheck the Show error alert box. Select OK to close. On the form, select one of the cells. You will see a drop down box on the right. Choose that then select a number 1-5. If you later select the cell, you can press delete to empty the cell. The drop down will still have your choices. You can set up a macro that will simply delete the contents of the cells you want to erase if you still want as mentioned above. You can set up one cell and copy/paste it elsewhere.

    Squeaky
    Hi Squeaky ,
    Could you send me a example maybe? Its a little bit hard to understand to me

  4. #4
    Forum Contributor
    Join Date
    08-12-2020
    Location
    Atlanta, Georgia
    MS-Off Ver
    Office 16
    Posts
    241

    Re: Ribbon for Clearing dropdown

    Hi gk,
    Here are the examples of what I was talking about.
    Attached Files Attached Files

+ 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. Clearing The Selected Value from a Ribbon Dropdown Control
    By Greg M in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-11-2021, 07:29 PM
  2. A dropdown how to fill on ribbon
    By glda19 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2018, 03:27 PM
  3. VBA / XML dropdown in ribbon
    By michiel soede in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2015, 10:35 AM
  4. Clearing Dropdown content based on value of another dropdown
    By JonathonHardy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-31-2011, 10:14 AM
  5. Excel Ribbon dropdown
    By VWood in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-15-2010, 12:07 PM
  6. clearing a dropdown menu
    By northernstar197 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-12-2007, 01:02 AM
  7. [SOLVED] Clearing associated dropdown fields
    By TC in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-31-2006, 04:20 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