Looping over checkboxes with VBA in Excel very slow









up vote
4
down vote

favorite
1












I have an Excel Sheet with about 4500 checkboxes (I know, it sounds stupid, but it is for a customer, please do not ask...).
Just wrote the VBA Sub below to uncheck all the boxes together. So far it works, but it is terribly slow, it takes more than 5 minutes until all boces are unchecked and while the Sub is running, the whole Excel Applikation grays out freezes. I know, 4500 Checkboxes is quiet a lot, but I wonder that it is really enough to bring Excel in such a trouble....Has anyone an idea?



Best
Michael



Sub DeselectAll()
Application.EnableCancelKey = False
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim wksA As Worksheet
Dim intRow As Integer

Set wksA = Worksheets("Companies")
For intRow = 1 To 4513
wksA.CheckBoxes("Checkbox_" & intRow).Value = False
Next
End Sub









share|improve this question







New contributor




Michael Schwed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Does this help a bit: If wksA.CheckBoxes("Check box " & intRow).Value = xlOn Then wksA.CheckBoxes("Check box " & intRow).Value = xlOff .+Don't forget to put your events back on.
    – EvR
    2 days ago










  • No, only the checkboxes
    – Michael Schwed
    2 days ago














up vote
4
down vote

favorite
1












I have an Excel Sheet with about 4500 checkboxes (I know, it sounds stupid, but it is for a customer, please do not ask...).
Just wrote the VBA Sub below to uncheck all the boxes together. So far it works, but it is terribly slow, it takes more than 5 minutes until all boces are unchecked and while the Sub is running, the whole Excel Applikation grays out freezes. I know, 4500 Checkboxes is quiet a lot, but I wonder that it is really enough to bring Excel in such a trouble....Has anyone an idea?



Best
Michael



Sub DeselectAll()
Application.EnableCancelKey = False
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim wksA As Worksheet
Dim intRow As Integer

Set wksA = Worksheets("Companies")
For intRow = 1 To 4513
wksA.CheckBoxes("Checkbox_" & intRow).Value = False
Next
End Sub









share|improve this question







New contributor




Michael Schwed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Does this help a bit: If wksA.CheckBoxes("Check box " & intRow).Value = xlOn Then wksA.CheckBoxes("Check box " & intRow).Value = xlOff .+Don't forget to put your events back on.
    – EvR
    2 days ago










  • No, only the checkboxes
    – Michael Schwed
    2 days ago












up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1





I have an Excel Sheet with about 4500 checkboxes (I know, it sounds stupid, but it is for a customer, please do not ask...).
Just wrote the VBA Sub below to uncheck all the boxes together. So far it works, but it is terribly slow, it takes more than 5 minutes until all boces are unchecked and while the Sub is running, the whole Excel Applikation grays out freezes. I know, 4500 Checkboxes is quiet a lot, but I wonder that it is really enough to bring Excel in such a trouble....Has anyone an idea?



Best
Michael



Sub DeselectAll()
Application.EnableCancelKey = False
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim wksA As Worksheet
Dim intRow As Integer

Set wksA = Worksheets("Companies")
For intRow = 1 To 4513
wksA.CheckBoxes("Checkbox_" & intRow).Value = False
Next
End Sub









share|improve this question







New contributor




Michael Schwed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have an Excel Sheet with about 4500 checkboxes (I know, it sounds stupid, but it is for a customer, please do not ask...).
Just wrote the VBA Sub below to uncheck all the boxes together. So far it works, but it is terribly slow, it takes more than 5 minutes until all boces are unchecked and while the Sub is running, the whole Excel Applikation grays out freezes. I know, 4500 Checkboxes is quiet a lot, but I wonder that it is really enough to bring Excel in such a trouble....Has anyone an idea?



Best
Michael



Sub DeselectAll()
Application.EnableCancelKey = False
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim wksA As Worksheet
Dim intRow As Integer

Set wksA = Worksheets("Companies")
For intRow = 1 To 4513
wksA.CheckBoxes("Checkbox_" & intRow).Value = False
Next
End Sub






excel vba performance loops checkbox






share|improve this question







New contributor




Michael Schwed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Michael Schwed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Michael Schwed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Michael Schwed

212




212




New contributor




Michael Schwed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Michael Schwed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Michael Schwed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Does this help a bit: If wksA.CheckBoxes("Check box " & intRow).Value = xlOn Then wksA.CheckBoxes("Check box " & intRow).Value = xlOff .+Don't forget to put your events back on.
    – EvR
    2 days ago










  • No, only the checkboxes
    – Michael Schwed
    2 days ago
















  • Does this help a bit: If wksA.CheckBoxes("Check box " & intRow).Value = xlOn Then wksA.CheckBoxes("Check box " & intRow).Value = xlOff .+Don't forget to put your events back on.
    – EvR
    2 days ago










  • No, only the checkboxes
    – Michael Schwed
    2 days ago















Does this help a bit: If wksA.CheckBoxes("Check box " & intRow).Value = xlOn Then wksA.CheckBoxes("Check box " & intRow).Value = xlOff .+Don't forget to put your events back on.
– EvR
2 days ago




Does this help a bit: If wksA.CheckBoxes("Check box " & intRow).Value = xlOn Then wksA.CheckBoxes("Check box " & intRow).Value = xlOff .+Don't forget to put your events back on.
– EvR
2 days ago












No, only the checkboxes
– Michael Schwed
2 days ago




No, only the checkboxes
– Michael Schwed
2 days ago












3 Answers
3






active

oldest

votes

















up vote
6
down vote













Without selection:



Sub DeselectAll()
With Worksheets("Companies").CheckBoxes
.Value = xlOff
End With
End Sub





share|improve this answer



























    up vote
    5
    down vote













    Just don't loop.



    This is a good example of when Selection can help:



    To set all checkboxes:



    Sub dural()
    ActiveSheet.CheckBoxes.Select
    Selection.Value = xlOn
    End Sub


    To uncheck all checkboxes:



    Sub dural2()
    ActiveSheet.CheckBoxes.Select
    Selection.Value = xlOf
    End Sub


    ( tested on Forms-type checkboxes )






    share|improve this answer




















    • without selection: Sub dural() With ActiveSheet.CheckBoxes .Value = xlOff End With End Sub Nice GS
      – EvR
      2 days ago











    • it's not necessary to use Select, you can assign the value directly: activesheet.checkboxes.value = xlOff
      – FunThomas
      2 days ago






    • 1




      @EvR thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
      – Gary's Student
      2 days ago










    • @FunThomas thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
      – Gary's Student
      2 days ago

















    up vote
    0
    down vote













    The best answer I thumbs up for is @EvR solution. I am not trying to answer but offering an idea of a workaround.



    I checked the time by adding 4000 ComboBox in blank sheet in a blank workbook with a simple 3 line loop (omg I forgot to off screen updating and calculations etc). It took around 10 minutes in my old laptop. I don’t have courage to repeat the ordeal again.



    When I tried to use your piece of code with looping it is taking 3-4 seconds only and with @EvR’s solution without loop and selection is taking 1-2 seconds. These times are actual time taken with Debug.Print or writing to some cells. Actual drama unfolds after screen updates, calculations, events are enabled with the sheet active. It become highly unstable and any careless click etc cause excel to ‘not responding’ state for 2-5 mintues.



    Though Customer and Boss are always right. Once in my life I succeeded to persuade someone in a similar approach of hundreds of buttons on a worksheet to something virtual. My Idea is to create virtual checkbox in the sheet. Proper cell sizing and border with validation of the cells to `=ChrW(&H2714)’ and ignore blank and a simple code like below can make it a pass-through type of work-around.



    Public Prvsel As Range
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim isect, Cl As Range
    Set isect = Application.Intersect(Target, Range("C1:C4000"))

    If isect Is Nothing Then
    Set Prvsel = Nothing 'Release multiple selection
    Exit Sub
    End If

    If isect.Cells.Count > 1 Then
    Set Prvsel = isect 'storing multiple selection for next click event
    Else
    If Target.Value = ChrW(&H2714) Then
    Target.Value = ""
    Else
    Target.Value = ChrW(&H2714)
    End If
    If Not Prvsel Is Nothing Then
    For Each Cl In Prvsel.Cells
    Cl.Value = Target.Value
    Next Cl
    End If
    End If
    End Sub


    ScreenShot






    share|improve this answer




















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      Michael Schwed is a new contributor. Be nice, and check out our Code of Conduct.









       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225157%2flooping-over-checkboxes-with-vba-in-excel-very-slow%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      6
      down vote













      Without selection:



      Sub DeselectAll()
      With Worksheets("Companies").CheckBoxes
      .Value = xlOff
      End With
      End Sub





      share|improve this answer
























        up vote
        6
        down vote













        Without selection:



        Sub DeselectAll()
        With Worksheets("Companies").CheckBoxes
        .Value = xlOff
        End With
        End Sub





        share|improve this answer






















          up vote
          6
          down vote










          up vote
          6
          down vote









          Without selection:



          Sub DeselectAll()
          With Worksheets("Companies").CheckBoxes
          .Value = xlOff
          End With
          End Sub





          share|improve this answer












          Without selection:



          Sub DeselectAll()
          With Worksheets("Companies").CheckBoxes
          .Value = xlOff
          End With
          End Sub






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          EvR

          9791312




          9791312






















              up vote
              5
              down vote













              Just don't loop.



              This is a good example of when Selection can help:



              To set all checkboxes:



              Sub dural()
              ActiveSheet.CheckBoxes.Select
              Selection.Value = xlOn
              End Sub


              To uncheck all checkboxes:



              Sub dural2()
              ActiveSheet.CheckBoxes.Select
              Selection.Value = xlOf
              End Sub


              ( tested on Forms-type checkboxes )






              share|improve this answer




















              • without selection: Sub dural() With ActiveSheet.CheckBoxes .Value = xlOff End With End Sub Nice GS
                – EvR
                2 days ago











              • it's not necessary to use Select, you can assign the value directly: activesheet.checkboxes.value = xlOff
                – FunThomas
                2 days ago






              • 1




                @EvR thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
                – Gary's Student
                2 days ago










              • @FunThomas thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
                – Gary's Student
                2 days ago














              up vote
              5
              down vote













              Just don't loop.



              This is a good example of when Selection can help:



              To set all checkboxes:



              Sub dural()
              ActiveSheet.CheckBoxes.Select
              Selection.Value = xlOn
              End Sub


              To uncheck all checkboxes:



              Sub dural2()
              ActiveSheet.CheckBoxes.Select
              Selection.Value = xlOf
              End Sub


              ( tested on Forms-type checkboxes )






              share|improve this answer




















              • without selection: Sub dural() With ActiveSheet.CheckBoxes .Value = xlOff End With End Sub Nice GS
                – EvR
                2 days ago











              • it's not necessary to use Select, you can assign the value directly: activesheet.checkboxes.value = xlOff
                – FunThomas
                2 days ago






              • 1




                @EvR thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
                – Gary's Student
                2 days ago










              • @FunThomas thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
                – Gary's Student
                2 days ago












              up vote
              5
              down vote










              up vote
              5
              down vote









              Just don't loop.



              This is a good example of when Selection can help:



              To set all checkboxes:



              Sub dural()
              ActiveSheet.CheckBoxes.Select
              Selection.Value = xlOn
              End Sub


              To uncheck all checkboxes:



              Sub dural2()
              ActiveSheet.CheckBoxes.Select
              Selection.Value = xlOf
              End Sub


              ( tested on Forms-type checkboxes )






              share|improve this answer












              Just don't loop.



              This is a good example of when Selection can help:



              To set all checkboxes:



              Sub dural()
              ActiveSheet.CheckBoxes.Select
              Selection.Value = xlOn
              End Sub


              To uncheck all checkboxes:



              Sub dural2()
              ActiveSheet.CheckBoxes.Select
              Selection.Value = xlOf
              End Sub


              ( tested on Forms-type checkboxes )







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 2 days ago









              Gary's Student

              71k93460




              71k93460











              • without selection: Sub dural() With ActiveSheet.CheckBoxes .Value = xlOff End With End Sub Nice GS
                – EvR
                2 days ago











              • it's not necessary to use Select, you can assign the value directly: activesheet.checkboxes.value = xlOff
                – FunThomas
                2 days ago






              • 1




                @EvR thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
                – Gary's Student
                2 days ago










              • @FunThomas thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
                – Gary's Student
                2 days ago
















              • without selection: Sub dural() With ActiveSheet.CheckBoxes .Value = xlOff End With End Sub Nice GS
                – EvR
                2 days ago











              • it's not necessary to use Select, you can assign the value directly: activesheet.checkboxes.value = xlOff
                – FunThomas
                2 days ago






              • 1




                @EvR thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
                – Gary's Student
                2 days ago










              • @FunThomas thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
                – Gary's Student
                2 days ago















              without selection: Sub dural() With ActiveSheet.CheckBoxes .Value = xlOff End With End Sub Nice GS
              – EvR
              2 days ago





              without selection: Sub dural() With ActiveSheet.CheckBoxes .Value = xlOff End With End Sub Nice GS
              – EvR
              2 days ago













              it's not necessary to use Select, you can assign the value directly: activesheet.checkboxes.value = xlOff
              – FunThomas
              2 days ago




              it's not necessary to use Select, you can assign the value directly: activesheet.checkboxes.value = xlOff
              – FunThomas
              2 days ago




              1




              1




              @EvR thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
              – Gary's Student
              2 days ago




              @EvR thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
              – Gary's Student
              2 days ago












              @FunThomas thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
              – Gary's Student
              2 days ago




              @FunThomas thanks....because the topic of grouping Objects is interesting, consider Posting you idea.
              – Gary's Student
              2 days ago










              up vote
              0
              down vote













              The best answer I thumbs up for is @EvR solution. I am not trying to answer but offering an idea of a workaround.



              I checked the time by adding 4000 ComboBox in blank sheet in a blank workbook with a simple 3 line loop (omg I forgot to off screen updating and calculations etc). It took around 10 minutes in my old laptop. I don’t have courage to repeat the ordeal again.



              When I tried to use your piece of code with looping it is taking 3-4 seconds only and with @EvR’s solution without loop and selection is taking 1-2 seconds. These times are actual time taken with Debug.Print or writing to some cells. Actual drama unfolds after screen updates, calculations, events are enabled with the sheet active. It become highly unstable and any careless click etc cause excel to ‘not responding’ state for 2-5 mintues.



              Though Customer and Boss are always right. Once in my life I succeeded to persuade someone in a similar approach of hundreds of buttons on a worksheet to something virtual. My Idea is to create virtual checkbox in the sheet. Proper cell sizing and border with validation of the cells to `=ChrW(&H2714)’ and ignore blank and a simple code like below can make it a pass-through type of work-around.



              Public Prvsel As Range
              Private Sub Worksheet_SelectionChange(ByVal Target As Range)
              Dim isect, Cl As Range
              Set isect = Application.Intersect(Target, Range("C1:C4000"))

              If isect Is Nothing Then
              Set Prvsel = Nothing 'Release multiple selection
              Exit Sub
              End If

              If isect.Cells.Count > 1 Then
              Set Prvsel = isect 'storing multiple selection for next click event
              Else
              If Target.Value = ChrW(&H2714) Then
              Target.Value = ""
              Else
              Target.Value = ChrW(&H2714)
              End If
              If Not Prvsel Is Nothing Then
              For Each Cl In Prvsel.Cells
              Cl.Value = Target.Value
              Next Cl
              End If
              End If
              End Sub


              ScreenShot






              share|improve this answer
























                up vote
                0
                down vote













                The best answer I thumbs up for is @EvR solution. I am not trying to answer but offering an idea of a workaround.



                I checked the time by adding 4000 ComboBox in blank sheet in a blank workbook with a simple 3 line loop (omg I forgot to off screen updating and calculations etc). It took around 10 minutes in my old laptop. I don’t have courage to repeat the ordeal again.



                When I tried to use your piece of code with looping it is taking 3-4 seconds only and with @EvR’s solution without loop and selection is taking 1-2 seconds. These times are actual time taken with Debug.Print or writing to some cells. Actual drama unfolds after screen updates, calculations, events are enabled with the sheet active. It become highly unstable and any careless click etc cause excel to ‘not responding’ state for 2-5 mintues.



                Though Customer and Boss are always right. Once in my life I succeeded to persuade someone in a similar approach of hundreds of buttons on a worksheet to something virtual. My Idea is to create virtual checkbox in the sheet. Proper cell sizing and border with validation of the cells to `=ChrW(&H2714)’ and ignore blank and a simple code like below can make it a pass-through type of work-around.



                Public Prvsel As Range
                Private Sub Worksheet_SelectionChange(ByVal Target As Range)
                Dim isect, Cl As Range
                Set isect = Application.Intersect(Target, Range("C1:C4000"))

                If isect Is Nothing Then
                Set Prvsel = Nothing 'Release multiple selection
                Exit Sub
                End If

                If isect.Cells.Count > 1 Then
                Set Prvsel = isect 'storing multiple selection for next click event
                Else
                If Target.Value = ChrW(&H2714) Then
                Target.Value = ""
                Else
                Target.Value = ChrW(&H2714)
                End If
                If Not Prvsel Is Nothing Then
                For Each Cl In Prvsel.Cells
                Cl.Value = Target.Value
                Next Cl
                End If
                End If
                End Sub


                ScreenShot






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  The best answer I thumbs up for is @EvR solution. I am not trying to answer but offering an idea of a workaround.



                  I checked the time by adding 4000 ComboBox in blank sheet in a blank workbook with a simple 3 line loop (omg I forgot to off screen updating and calculations etc). It took around 10 minutes in my old laptop. I don’t have courage to repeat the ordeal again.



                  When I tried to use your piece of code with looping it is taking 3-4 seconds only and with @EvR’s solution without loop and selection is taking 1-2 seconds. These times are actual time taken with Debug.Print or writing to some cells. Actual drama unfolds after screen updates, calculations, events are enabled with the sheet active. It become highly unstable and any careless click etc cause excel to ‘not responding’ state for 2-5 mintues.



                  Though Customer and Boss are always right. Once in my life I succeeded to persuade someone in a similar approach of hundreds of buttons on a worksheet to something virtual. My Idea is to create virtual checkbox in the sheet. Proper cell sizing and border with validation of the cells to `=ChrW(&H2714)’ and ignore blank and a simple code like below can make it a pass-through type of work-around.



                  Public Prvsel As Range
                  Private Sub Worksheet_SelectionChange(ByVal Target As Range)
                  Dim isect, Cl As Range
                  Set isect = Application.Intersect(Target, Range("C1:C4000"))

                  If isect Is Nothing Then
                  Set Prvsel = Nothing 'Release multiple selection
                  Exit Sub
                  End If

                  If isect.Cells.Count > 1 Then
                  Set Prvsel = isect 'storing multiple selection for next click event
                  Else
                  If Target.Value = ChrW(&H2714) Then
                  Target.Value = ""
                  Else
                  Target.Value = ChrW(&H2714)
                  End If
                  If Not Prvsel Is Nothing Then
                  For Each Cl In Prvsel.Cells
                  Cl.Value = Target.Value
                  Next Cl
                  End If
                  End If
                  End Sub


                  ScreenShot






                  share|improve this answer












                  The best answer I thumbs up for is @EvR solution. I am not trying to answer but offering an idea of a workaround.



                  I checked the time by adding 4000 ComboBox in blank sheet in a blank workbook with a simple 3 line loop (omg I forgot to off screen updating and calculations etc). It took around 10 minutes in my old laptop. I don’t have courage to repeat the ordeal again.



                  When I tried to use your piece of code with looping it is taking 3-4 seconds only and with @EvR’s solution without loop and selection is taking 1-2 seconds. These times are actual time taken with Debug.Print or writing to some cells. Actual drama unfolds after screen updates, calculations, events are enabled with the sheet active. It become highly unstable and any careless click etc cause excel to ‘not responding’ state for 2-5 mintues.



                  Though Customer and Boss are always right. Once in my life I succeeded to persuade someone in a similar approach of hundreds of buttons on a worksheet to something virtual. My Idea is to create virtual checkbox in the sheet. Proper cell sizing and border with validation of the cells to `=ChrW(&H2714)’ and ignore blank and a simple code like below can make it a pass-through type of work-around.



                  Public Prvsel As Range
                  Private Sub Worksheet_SelectionChange(ByVal Target As Range)
                  Dim isect, Cl As Range
                  Set isect = Application.Intersect(Target, Range("C1:C4000"))

                  If isect Is Nothing Then
                  Set Prvsel = Nothing 'Release multiple selection
                  Exit Sub
                  End If

                  If isect.Cells.Count > 1 Then
                  Set Prvsel = isect 'storing multiple selection for next click event
                  Else
                  If Target.Value = ChrW(&H2714) Then
                  Target.Value = ""
                  Else
                  Target.Value = ChrW(&H2714)
                  End If
                  If Not Prvsel Is Nothing Then
                  For Each Cl In Prvsel.Cells
                  Cl.Value = Target.Value
                  Next Cl
                  End If
                  End If
                  End Sub


                  ScreenShot







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  Ahmed AU

                  36018




                  36018




















                      Michael Schwed is a new contributor. Be nice, and check out our Code of Conduct.









                       

                      draft saved


                      draft discarded


















                      Michael Schwed is a new contributor. Be nice, and check out our Code of Conduct.












                      Michael Schwed is a new contributor. Be nice, and check out our Code of Conduct.











                      Michael Schwed is a new contributor. Be nice, and check out our Code of Conduct.













                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225157%2flooping-over-checkboxes-with-vba-in-excel-very-slow%23new-answer', 'question_page');

                      );

                      Post as a guest














































































                      Popular posts from this blog

                      Use pre created SQLite database for Android project in kotlin

                      Darth Vader #20

                      Ondo