Results 1 to 2 of 2

error with assigning macro to form buttons

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    error with assigning macro to form buttons

    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?
    Last edited by jordan2322; 01-16-2012 at 08:13 PM.

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