Using True and False to select items to print

Posted by user1753915 on Stack Overflow See other posts from Stack Overflow or by user1753915
Published on 2012-10-17T16:57:28Z Indexed on 2012/10/17 17:00 UTC
Read the original article Hit count: 216

Filed under:
|

I have a workbook that contains rows of information that needs to printed to a seperate worksheet in excel. I am trying to utilize a checkbox to indicate which items need to print and which items need to be skipped. The checkbox is located in column "A" and once checked and the macro ran, I want it to pick up the data in each cell of that particular row, transfer it a seperate worksheet (form), prompt and save the worksheet to pdf, clear the form, and then return to the main worksheet to continue until all rows have been checked. However, right now, my code is only looping through the very first "TRUE" statement and not continuing to the rest. Here is the code:

Private Sub CommandButton1_Click() On Error GoTo ErrHandler:

Dim i As Integer For i = 1 To 10 If ActiveSheet.OLEObjects("CheckBox" & i).Object.Value = False Then Else If ActiveSheet.OLEObjects("CheckBox" & i).Object.Value = True Then Call PrintWO Else End If Do Until ActiveSheet.OLEObjects("CheckBox" & i).Object.Value = 10 MsgBox "Nothing Selected to Print" Exit Do Exit Sub Loop End If Next i ErrHandler: End Sub

© Stack Overflow or respective owner

Related posts about loops

Related posts about checkboxes