Rayne
asked on
form Controls change in excel
Hello All,
I currently have all checkboxes in the worksheet that use auto filter to filter and copy data to another sheet. Everything is working all right. I just need to make a change. The checkboxes that refer to the M series like M1,M2,M3,M4,M5 needs to be in button mode, Not in checkboxes
.. and the Rest of the checkboxes remain the way they are. And the filtering happens just the same
Now to change that in vba – for each controls in the worksheet, filter accordingly - can anyone help?
Attached file….
Thank you
R
somecheckboxes2ButtonsLoop.xlsm
I currently have all checkboxes in the worksheet that use auto filter to filter and copy data to another sheet. Everything is working all right. I just need to make a change. The checkboxes that refer to the M series like M1,M2,M3,M4,M5 needs to be in button mode, Not in checkboxes
.. and the Rest of the checkboxes remain the way they are. And the filtering happens just the same
Now to change that in vba – for each controls in the worksheet, filter accordingly - can anyone help?
Attached file….
Thank you
R
somecheckboxes2ButtonsLoop.xlsm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok - that's what you got. Check it out and see if the behavior is what you want.
Dave
Dave
ASKER
Hello Dave,
If you can demo the push button, I can take a look – yes it would make more sense to see the state in which the section is..
Yes, that makes a lot of sense - With push buttons; it’s hard to visibly show the "state" that the button push would be in.
Users will first filter the data by M series and then sub filter them by the other checkboxes
R
If you can demo the push button, I can take a look – yes it would make more sense to see the state in which the section is..
Yes, that makes a lot of sense - With push buttons; it’s hard to visibly show the "state" that the button push would be in.
Users will first filter the data by M series and then sub filter them by the other checkboxes
R
ASKER
Thanks again Dave for your quick help. The command button works great. If you have time and this is less complex, then you may post the in / out button and I can take a look.
R
R
There's a couple ways to do this. The push buttons are activeX controls (so caveats about using them in worksheets. While I do, some folks have quirky resize problems, so most MVPs will tell you not to use them except in userforms).
Moving on...
1. Could create a click event for each button toggled, and do work from there,
2. Or, do it in the script we already have, and just check the state of the push button.
Since we have to have event code anyway when the toggle happens, I'm doing it via #1, above, so will be similar to the command button routine.
so in the MainViewSheet codepage we have code like this:
And for initialize we have added code like this:
We check the name as with check boxes, to ensure we don't change toggle buttons or check boxes we don't want to - there could be others we DON'T want to use with the filtering, which is why we named them in the first place ;)
PS - at some point, you'll want to know how to do an event or change based on a change to ANY control, without having to create a function/subroutine STUB for each control as we have done in this workbook. When you're ready, ask that question as there are classes that can be developed that check for clicks all in one set of code.
Dave
somecheckboxes2ButtonsLoop-r2.xlsm
Moving on...
1. Could create a click event for each button toggled, and do work from there,
2. Or, do it in the script we already have, and just check the state of the push button.
Since we have to have event code anyway when the toggle happens, I'm doing it via #1, above, so will be similar to the command button routine.
so in the MainViewSheet codepage we have code like this:
Private Sub TB_1_Click()
[m123_Range].Columns(2).Cells(1).Value = IIf(TB_1.Value = -1, 1, 0)
Call doFilterGetResults
End Sub
And for initialize we have added code like this:
Sub CBInitialize(wks As Worksheet)
Dim cBox As CheckBox
Dim objOLE As OLEObject
'initialize all CheckBoxes to FALSE
For Each cBox In wks.CheckBoxes
If Left(UCase(cBox.Name), 2) = "CB" Then
cBox.Value = False
End If
Next cBox
'initialize all toggle buttons to FALSE
For Each objOLE In wks.OLEObjects
If objOLE.progID = "Forms.ToggleButton.1" And Left(objOLE.Name, 2) = "TB" Then
objOLE.Object.Value = False
End If
Next objOLE
Call clearMain(wks)
End Sub
We check the name as with check boxes, to ensure we don't change toggle buttons or check boxes we don't want to - there could be others we DON'T want to use with the filtering, which is why we named them in the first place ;)
PS - at some point, you'll want to know how to do an event or change based on a change to ANY control, without having to create a function/subroutine STUB for each control as we have done in this workbook. When you're ready, ask that question as there are classes that can be developed that check for clicks all in one set of code.
Dave
somecheckboxes2ButtonsLoop-r2.xlsm
ASKER
Hello Dave,
That is great. This button looks way better than the other one and shows the state – that’s perfect. Yes, I will ask that question next for the event handling. Way less code than what I have got now :)
R
That is great. This button looks way better than the other one and shows the state – that’s perfect. Yes, I will ask that question next for the event handling. Way less code than what I have got now :)
R
Here's a tip - instead of assigning a new macro to each checkbox (which in turn calls the same macro) just have each checkbox call the main macro that needs to be called.
Not sure why I didn't point that out, earlier.
Just have all the checkboxes that end up calling doFilterGetResults() just linked to doFilterGetResults() rather than a _Click macro that calls doFilterGetResults().
Cheers,
Dave
Not sure why I didn't point that out, earlier.
Just have all the checkboxes that end up calling doFilterGetResults() just linked to doFilterGetResults() rather than a _Click macro that calls doFilterGetResults().
Cheers,
Dave
ASKER
Hello Dave,
I have posted two questions in EE
https://www.experts-exchange.com/questions/27678921/Excel-Data-copy.html
https://www.experts-exchange.com/questions/27678898/Excel-column-to-add-as-filter.html
When you have time, you may take a look. I have attached files in both cases.
Thank you :)
R
I have posted two questions in EE
https://www.experts-exchange.com/questions/27678921/Excel-Data-copy.html
https://www.experts-exchange.com/questions/27678898/Excel-column-to-add-as-filter.html
When you have time, you may take a look. I have attached files in both cases.
Thank you :)
R
ASKER
Thank you for replying :)
I need need command buttons for this.
R