News, tips, advice, support for Windows, Office, PCs & more. Tech help. No bull. We're community supported by donations from our Plus Members, and proud of it
Home icon Home icon Home icon Email icon RSS icon
  • Calling a macro from a command button click

    Posted on WSMartinM Comment on the AskWoody Lounge

    Home Forums AskWoody support Productivity software by function MS Excel and spreadsheet help Calling a macro from a command button click

    Topic Resolution: Resolved
    Viewing 1 reply thread
    • Author
      • #2002363 Reply
        AskWoody Lounger

        I’ve a simple macro named “Sort” that sorts a named range in the way I want. It works fine.

        On another worksheet in the same workbook I have a Command Button with the following worksheet code:

        Private Sub SortData_Click()
        Call Sort
        End Sub

        Clicking the Command Button  throws up an error “Complie error: Invalid use of property”, with the line Private Sub SortData_Click() in yellow.

        Other Command Buttons, some with complex code, are working OK.

        What am I doing wrong ?

      • #2002385 Reply
        AskWoody Lounger

        Solved !
        I had the same name for the Command Button and the macro
        My bad.

    Viewing 1 reply thread

    Please follow the -Lounge Rules- no personal attacks, no swearing, and politics/religion are relegated to the Rants forum.

    Reply To: Calling a macro from a command button click

    You can use BBCodes to format your content.
    Your account can't use Advanced BBCodes, they will be stripped before saving.