Results 1 to 2 of 2

Thread: Two checkbox in ribbon working together

  1. #1

    Post Two checkbox in ribbon working together



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I add two checkBoxes in the ribbon using xml with that code (with Custom UI Editor for Microsoft Office)

    <checkBox id ="F16" label="F16" onAction="Show_Column" />
    <checkBox id ="F20" label="F20" onAction="Show_Column" />

    That execute this vba code :

    Sub Show_Column(control As IRibbonControl, pressed As Boolean)
    Dim strn As String
    ActiveSheet.Cells.EntireColumn.Hidden = False
    Range("B:ZZ").EntireColumn.Hidden = True
    strn = control.id
    Search strn, pressed
    End If
    End Sub
    Sub Search(fnd As String, pressed As Boolean)
    If pressed = True Then
    Dim firstfound As String
    Dim foundcell As Range,rng As Range
    Dim myRange As Range, lastcell As Range
    Set myRange = ActiveSheet.UsedRange
    Set lastcell = myRange.Cells(myRange.Cells.Count)
    Set foundcell = myRange.Find(what:=fnd, after:=lastcell)
    If Not foundcell Is Nothing Then firstfound = foundcell.Address
    End If
    Set rng = foundcell
    Do Until foundcell Is Nothing
    Set foundcell = myRange.FindNext(after:=foundcell)
    Set rng = Union(rng, foundcell)
    If foundcell.Address = firstfound Then Exit Do
    Loop
    rng.EntireColumn.Hidden = False
    Else
    Exit Sub
    End If

    As you can see it searches the id of the checkbox and hide other datas. What I need to do is to make this checkBoxes to work together to show all checked datas.Any help would be greatly appreciated.

    Last edited by cagataybaser; 2014-08-18 at 09:21 AM.

  2. #2
    Conjurer WizzardOfOz's Avatar
    Join Date
    Sep 2013
    Location
    Australia
    Posts
    184
    Articles
    0
    See my reply earlier to your other thread.
    Add public variables to control pressed or not.
    Use the onload to get the ribbon.
    Use getPressed to set check boxes based on public variables
    Use Invalidate to refresh ribbon

Posting Permissions

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