+ Reply to Thread
Results 1 to 4 of 4

Rectangle that activates a macro

  1. #1
    Guest

    Rectangle that activates a macro

    I have a macro assigned to a number of rectangles. When a
    specific rectangle is clicked to activate the macro, I
    need the macro to identify which rectangle (ex: "Rectangle
    3") was clicked to activate the macro.
    How would I do that?

  2. #2
    Tom Ogilvy
    Guest

    Re: Rectangle that activates a macro

    Assign the macro to that rectangle


    Public Sub Rec_click()
    Dim sname as String
    Dim rec as Rectangle

    sName = application.caller
    set rec = activeSheet.Rectangels(sName)
    msgbox rec.Name
    End Sub

    --
    Regards,
    Tom Ogilvy


    <[email protected]> wrote in message
    news:[email protected]...
    > I have a macro assigned to a number of rectangles. When a
    > specific rectangle is clicked to activate the macro, I
    > need the macro to identify which rectangle (ex: "Rectangle
    > 3") was clicked to activate the macro.
    > How would I do that?




  3. #3
    JE McGimpsey
    Guest

    Re: Rectangle that activates a macro

    Take a look at Application.Caller..

    Public Sub LotsOfCallers()
    Dim sWhich As String
    sWhich = Application.Caller
    MsgBox sWhich
    End Sub



    In article <[email protected]>,
    <[email protected]> wrote:

    > I have a macro assigned to a number of rectangles. When a
    > specific rectangle is clicked to activate the macro, I
    > need the macro to identify which rectangle (ex: "Rectangle
    > 3") was clicked to activate the macro.
    > How would I do that?


  4. #4
    PaulD
    Guest

    Re: Rectangle that activates a macro

    I would guess each rectangle has an on_click event so just pass some
    indentifier as an arguement to your macro. Something like this
    Private Sub Rectangle1_Click()
    yourmacro "rec1"
    End Sub
    Private Sub Rectangle2_Click()
    yourmacro "rec2"
    End Sub

    then for your macro

    Sub yourmacro(WhichRectangle as String)
    your code here
    End Sub

    the value WhichRectangle will tell you what was clicked to start your macro

    Paul D

    <[email protected]> wrote in message
    news:[email protected]...
    > I have a macro assigned to a number of rectangles. When a
    > specific rectangle is clicked to activate the macro, I
    > need the macro to identify which rectangle (ex: "Rectangle
    > 3") was clicked to activate the macro.
    > How would I do that?




+ Reply to Thread

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