0

I have 98 checkboxes embedded in my worksheet (Orders).

I want to select certain checkboxes then click a command button that will iterate through the checkboxes. If checked, I want to send the information in that line to the next blank line on another worksheet (Sub COMPLETE). Then I want to clear the information on that line and move the lines after that up a line.

When I step through the sub, I get:

error 1004 'Application-defined or object-defined error'

at the If statement.

Private Sub cmbupdate_Click()  
    Dim i As Long  

    For i = 1 To 98  
        If CheckBoxes("CheckBox" & i).Value = True Then  
            Range("A" & (i + 3), "K" & (i + 3)).Select  
            Selection.Copy  
            COMPLETE  
            Selection.ClearContents  
            Range("A" & (i + 3).Select  
            ActiveCell.Offset(1).Select  
            Orders.Range(Selection, Selection.Offset(10)).Select  
            Orders.Range(Selection, Selection.End(xlDown)).Select  
            Selection.Cut Range("A" & (i + 3))  
            Range("A5", "K101").Select  
            AddBorder  
            Range("A4").Select  
            CheckBoxes("Checkbox" & i).Value = False  
        End If  
    Next  
End Sub
Community
  • 1
  • 1
PJ W.
  • 1
  • 3
  • 1
    [This](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) will help you to greatly improve your code. – Miles Fett Oct 24 '19 at 18:28

1 Answers1

0

The CheckBoxes() function wants an index instead of a name. Try to only use the number of i to check. Also an if statement allready checks if a statement is true , so the "= true" is not needed.

If CheckBoxes(i).Value Then
Steffen
  • 121
  • 6