I am receiving the error "Cant execute code in break mode" on the line:
If Selection = xlButtonControl Then
in the code below
This is to assign the macro HideCrews to each of the form buttons on the worksheets
Sub AssignMacro()
Dim i As Integer
With ActiveSheet
For i = 1 To .Shapes.Count
If .Shapes.Item(i).Type = msoFormControl Then
.Select
If Selection = xlButtonControl Then
.Shapes.Item(i).OnAction = "HideCrews"
End If
End If
Next i
End With
End Sub
i want this macro to run when i click the button
Sub HideCrews()
Dim i As Integer
Dim j As String
Dim Col As String
Dim Sht As String
Application.ScreenUpdating = False
Col = Sheets("Data").Cells(8, 1).Value
Sht = ActiveSheet.Name
Sheets("Data").Visible = True
Sheets("Data").Select
Sheets("Data").Range(Col & "3").Select
Selection.End(xlDown).Select
j = ActiveCell.Row
For i = 3 To j
On Error Resume Next
Sheets(Sht).Select
If (Sheets("Data").Cells(i, Col).Offset(, 1).Value = "0") Then
Sheets(Sht).Range(Sheets("Data").Range(Col & i)).EntireRow.Hidden = True
End If
Next i
Application.ScreenUpdating = True
End Sub
How do i fix this error?
Bookmarks