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
RayneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dlmilleCommented:
Do you want command buttons or IN/OUT buttons (which work like checkboxes) for the M-Series?

With buttons, I assume you want them ON or OFF based on the push of the button.

we just create macros against each button like:

    [m123_Range].Columns(2).Cells(1).Value = IIf([m123_Range].Columns(2).Cells(1).Value = 1, 0, 1)
    Call doFilterGetResults
End Sub

and then comment out the test for the M1-M5 checkbox in the loop.

See attached.

With In/Out buttons, the behavior would be more like with checkboxes.  With push buttons, its hard to visibly show the "state" that the button push would be in.

Let me know if this is what you're looking for or if you want to try the IN/OUT buttons.

Dave
somecheckboxes2ButtonsLoop-r1.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RayneAuthor Commented:
Hello Dave,

Thank you for replying :)
I need need command buttons for this.

R
0
dlmilleCommented:
Ok - that's what you got.  Check it out and see if the behavior is what you want.

Dave
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

RayneAuthor Commented:
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
0
RayneAuthor Commented:
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
0
dlmilleCommented:
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:

Private Sub TB_1_Click()
    [m123_Range].Columns(2).Cells(1).Value = IIf(TB_1.Value = -1, 1, 0)
    Call doFilterGetResults
End Sub

Open in new window


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

Open in new window


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
0
RayneAuthor Commented:
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
0
dlmilleCommented:
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
0
RayneAuthor Commented:
Hello Dave,

I have posted two questions in EE

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Q_27678921.html
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Q_27678898.html

When you have time, you may take a look. I have attached files in both cases.

Thank you :)

R
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.