dlherr1988
New Member
- Joined
- Jun 11, 2009
- Messages
- 4
I'm building a userform that has four list boxes on it which autopopulate the headers from a large dataset. The users can then select (or multi-select) the headers in each list box to filter the data.
I've run into a problem where if listboxA and listboxB have the same selection (say "date") the macro that runs when the user pushes the ok button stops. It makes sense for the user not to be able to make the same selection in multiple list boxes for this macro.
Basically I'm having trouble with the code to remove the value ("date" or any other) from boxes B, C, and D when it is selected in A and then adding that same value back in if it is deselected
Private Sub lbFilter_Change()
For i = 0 To frmPivot.lbFilter.ListCount - 1
If frmPivot.lbFilter.Selected(i) = True Then
frmPivot.lbRow.RemoveItem i
End If
Next i For i = 0 To frmPivot.lbFilter.ListCount - 1
If frmPivot.lbFilter.Selected(i) = False Then
frmPivot.lbRow.AddItem i
End If
Next i
End Sub
Right now if you click "date" in lbFilter it is removed from the remaining list boxes. However if you deselect it the index number for i is added back in (say "1"). This creates a tornado where now removing "revenue" from lbFilter removes "Profit" from the remaining list boxes because the indexes are messed up.
Any help on getting this macro to remove the actual Value and replace that same Value would be much appreciated!
I've run into a problem where if listboxA and listboxB have the same selection (say "date") the macro that runs when the user pushes the ok button stops. It makes sense for the user not to be able to make the same selection in multiple list boxes for this macro.
Basically I'm having trouble with the code to remove the value ("date" or any other) from boxes B, C, and D when it is selected in A and then adding that same value back in if it is deselected
Private Sub lbFilter_Change()
For i = 0 To frmPivot.lbFilter.ListCount - 1
If frmPivot.lbFilter.Selected(i) = True Then
frmPivot.lbRow.RemoveItem i
End If
Next i For i = 0 To frmPivot.lbFilter.ListCount - 1
If frmPivot.lbFilter.Selected(i) = False Then
frmPivot.lbRow.AddItem i
End If
Next i
End Sub
Right now if you click "date" in lbFilter it is removed from the remaining list boxes. However if you deselect it the index number for i is added back in (say "1"). This creates a tornado where now removing "revenue" from lbFilter removes "Profit" from the remaining list boxes because the indexes are messed up.
Any help on getting this macro to remove the actual Value and replace that same Value would be much appreciated!