none
If Statement Assistance RRS feed

  • Question

  • Hello all - 

    So without going to much into detail, does anyone know or have any ideas how or if I can combine the below in someway? It appears I am limited to how many connecting lines I can have (25 max?). Lol I actually need it to go through 25 more lines in addition to the 25 shown below...

    Wednesday, June 29, 2016 11:53 PM

Answers

  • Hi rstreets2,

    I try to run your code and find that it is working correctly on my side.

    I try to test by checking and unchecking the textboxes multiple times.

    if condition executed correctly.

    I got error in the line below. both if and else section contains these lines.

      Sheets("ICA Coversheet").Multi_Select_Props.Visible = False
                 Sheets("ICA Coversheet").ViewProps.Visible = True

    because Multi_Select_Props and ViewProps are not available. please try to check this line and correct it.

    Remove these and again try to execute the code.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 14, 2016 5:26 AM
    Moderator

All replies

  • Sub Test()
      Dim OO As OLEObject
      Dim Checked As Boolean
      For Each OO In Worksheets("Properties").OLEObjects
        Select Case OO.progID
          Case "Forms.CheckBox.1"
            Checked = Checked Or OO.Object.Value
        End Select
      Next
      If Checked Then
        'At min. one of the checkboxes is checked
      Else
        'All checkboxes are unchecked
      End If
    End Sub
    

    Thursday, June 30, 2016 7:17 AM
  • Hi Andreas and thank you for your assistance :)

    I am having some difficulty with your suggestion :( It does not seem to recognize the "If Checked Then" portion of the code...no matter what, checkboxes checked or not,  the only part of the code that seems to trigger any changes is the "Else" or second portion of the code? Any ideas as to what may be causing this?

    Here is what I have...

    Public Sub MultiSelectView_Click()

        Dim OO As OLEObject
        Dim Checked As Boolean    
        For Each OO In Worksheets("Properties").OLEObjects
        Select Case OO.progID
        Case "Forms.CheckBox.1"
        Checked = Checked Or OO.Object.Value
        End Select
        Next
            If Checked Then
            'At min. one of the checkboxes is checked
                Sheets("ICA Coversheet").Multi_Select_Props.Visible = False
                Sheets("ICA Coversheet").ViewProps.Visible = True
            Else
            'All checkboxes are unchecked
                Sheets("ICA Coversheet").Multi_Select_Props.Visible = True
                Sheets("ICA Coversheet").ViewProps.Visible = False
            End If
    End Sub


    • Edited by rstreets2 Friday, July 1, 2016 6:35 PM Typo
    Friday, July 1, 2016 6:32 PM
  • Also probably should note...The button that is calling this code is on a separate sheet (ICA Coversheet)...the check boxes in questions are on another sheet (Properties)...not sure if this makes much of a difference? I have tried to isolate each sheet when being called upon (displaying tabs, selecting sheets, etc.) to no avail :(

    Is there a limit to the number of checkboxes this can check at one time? I have a total of 236 checkboxes to review?

    Friday, July 1, 2016 6:43 PM
  • Is there a limit to the number of checkboxes this can check at one time?

    No, the code should work. But maybe you don't use ActiveX Checkboxes??

    I need to see your file, please upload it here:
    https://www.dropbox.com/request/nOXAKnCPKt1pbmkSuNh0

    Andreas.

    Saturday, July 2, 2016 9:53 AM
  • Hi rstreets2,

    can you please tell us which type of textboxes are you using on your sheet?

    are they Form controls check box or they Activex control checkbox.

    if they are not Activex please try to make a test with Active x checkbox.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 7, 2016 7:31 AM
    Moderator
  • Hi Deepak - Sorry for the delayed response. got sidetracked with another project. Anyhow...both textboxes and checkboxes are all ActiveX
    Wednesday, July 13, 2016 9:01 PM
  • Hi rstreets2,

    I try to run your code and find that it is working correctly on my side.

    I try to test by checking and unchecking the textboxes multiple times.

    if condition executed correctly.

    I got error in the line below. both if and else section contains these lines.

      Sheets("ICA Coversheet").Multi_Select_Props.Visible = False
                 Sheets("ICA Coversheet").ViewProps.Visible = True

    because Multi_Select_Props and ViewProps are not available. please try to check this line and correct it.

    Remove these and again try to execute the code.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 14, 2016 5:26 AM
    Moderator