0

I'm working on a searchfilter on 70+ checkbox choices. On each page from a multipage I've generated 44 checkboxes from an excel sheet.

I'm almost done with the searchfilter. My only issue is that I can't find a way to move a checkbox on page2 to page1 of a multipage.

Moving the checkbox to page1 will preserve the selection of the checkboxes so that is the reason to NOT generate the checkboxes again. Another reason is that the generation of checkboxes is will freeze the userform for a couple seconds.

Currently I've the following idea to move the checkbox on page2 to page1:

C.Parent.Name = "Page" &VAR_Sub.curMultipage + 1`    

However changing the Parent.Name doesn't seem to move the checkbox to page1. I"ve confirmed that C.Parent.Name was Page2 and it has changed to Page1. C is the checkbox.

The code for looping:

For Each C In UserForm1.MultiPage1.Pages(UserForm1.MultiPage1.Value).Controls
     `If TypeName(C) = "CheckBox" Then
          VAR_Sub.i = VAR_Sub.i + 1
          If InStr(1, C.Caption, strSearchTerm, vbTextCompare) = 0 Then
              C.Visible = False
          Else
          C.Visible = True
          If Var_Sub.i > 44 Then
              chkName = C.Parent.Name
              'MsgBox "OLD" & chkName
              C.Parent.Name = "Page" & VAR_Sub.curMultiPage + 1
              chkName = C.Parent.Name
              'MsgBox "NEW" & chkName
          End If
         ''Below more positioning code
             ....
     End If`
 Next C

Thanks in advance and kind regards. PS: If my post is lacking something, please give me a heads up. I will improve it.

I try to achieve this: Wanted result

Currently I have achieved the following: Page1 with generated checkboxes Page2 with generated checkboxes Using the filter results into: Page1 after filter Page2 after filter

As you can see in the images above of what I have achieved, the checkboxes are on a different page of a multipage. Even though the parent.name has been changed to Page1

Added pictures of what I"m trying to achieve. Currently I"m trying to achieve the above with a listbox.

Vergil
  • 1
  • 2
  • 1
    Needing to move controls around smells funny, this is very likely an X-Y problem. What you need is probably a `ListBox` control with checkbox style turned on. Simply add items checked in the listbox, and when the user unchecks an item in the listbox, remove that item from the listbox. No control moves anywhere. – Mathieu Guindon Jun 06 '18 at 17:26
  • Thanks Mathieu, I will try to use the ListBox. Actually I don't want the listbox to dissapear when unchecked. I have 70+ checkboxes. Each checkbox selection generates a different section in the Word document. (I will add screenshots of what I have achieved and want to achieve a couple hours later) Using the filter I hide the checkboxes that do not contain the searchword. I am able to reposition the checkboxes, just that it's not possible to reposition the checkbox on page1 instead of page2 of the multipage. I will experiment with the ListBox and see if It's possible to achieve it. – Vergil Jun 06 '18 at 18:03

0 Answers0