+ Reply to Thread
Results 1 to 3 of 3

Thread: Assign Macro

  1. #1
    James Hamilton
    Guest

    Assign Macro

    I want to write a macro which brings up a msg box when a particular cell is
    selected.

    I've written the macro, and when I run it from the VB editor the message box
    appears, but when I go back to excel and select the particular cell, it
    doesn't work.

    How do I "assign" the macro to the cell?

    Thanks.


  2. #2
    Don Guillett
    Guest

    Re: Assign Macro

    event code must be in the sheet module of the desired sheet

    --
    Don Guillett
    SalesAid Software
    donaldb@281.com
    "James Hamilton" <mailforme@optusnet.com.au> wrote in message
    news:3DC3F116-D4B1-4AEF-BF94-19F8AF52A64D@microsoft.com...
    > I want to write a macro which brings up a msg box when a particular cell

    is
    > selected.
    >
    > I've written the macro, and when I run it from the VB editor the message

    box
    > appears, but when I go back to excel and select the particular cell, it
    > doesn't work.
    >
    > How do I "assign" the macro to the cell?
    >
    > Thanks.
    >




  3. #3
    Harald Staff
    Guest

    Re: Assign Macro

    Rightclick the sheet tab in question, find the selection-change event and
    call it from there after validating that it's the right cell, like

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target(1).Address = "$B$12" Then Call MyMsgboxMacro
    End Sub

    If I were a catholic I'd go to church tomorrow and confess "Father, I have
    sinned, I helped a stranger on the internet to create this terrible thing".
    A MSGBOX when you enter a cell ? How can that be anything but annoying, what
    good can it possible do, how would you react to such a thing, would you
    read, digest and obey ? Don't, please don't.

    Best wishes Harald

    "James Hamilton" <mailforme@optusnet.com.au> skrev i melding
    news:3DC3F116-D4B1-4AEF-BF94-19F8AF52A64D@microsoft.com...
    > I want to write a macro which brings up a msg box when a particular cell

    is
    > selected.
    >
    > I've written the macro, and when I run it from the VB editor the message

    box
    > appears, but when I go back to excel and select the particular cell, it
    > doesn't work.
    >
    > How do I "assign" the macro to the cell?
    >
    > Thanks.
    >




+ 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.2.0