+ Reply to Thread
Results 1 to 2 of 2

How to start and stop a loop base on condition.

Hybrid View

  1. #1
    Registered User
    Join Date
    08-21-2006
    Posts
    10

    Smile How to start and stop a loop base on condition.

    Hi,

    I have a piece of code that put a check in all checkbox
    in column B from row 5 to row 50 but in column C, I have
    data from row 5 to 38. I want the macro to stop at row
    38 in column B. When the cell in column C is empty stop
    putting checks in column B.

    How can I make this macro Check all checkbox down column B
    and stop when column C is empty..

    How do I add a loop to stop when the cell in column C is empty?

    Private Sub CommandButton1_Click()

    Dim CB As Variant
    For Each CB In ActiveSheet.CheckBoxes
    CB.Value = False
    Next
    End Sub

    .....A.......B............C...............
    ....1S......X............Ms..............
    ....1M......X............Mr. &. Mrs....
    ....1S......X............Ms..............
    ....1S......X............ ...............

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,936
    The following mods worked fine for my little five cb test sheet:

    Private Sub CommandButton1_Click()
    Dim CB As Variant
    dim iRow as integer
    iRow = 1


    For Each CB In ActiveSheet.CheckBoxes
    if cells(iRow,3).value="" then
    CB.Value = False
    end if
    iRow = iRow +1
    Next
    End Sub
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1