+ Reply to Thread
Results 1 to 4 of 4

Can macros output to a cell selected prior to running it?

  1. #1
    winnie
    Guest

    Can macros output to a cell selected prior to running it?

    I need to know if it is possible to run a macro from a cel that you specify
    right before runing the macro (i.e. a variable cell rather than the same
    constant cell which is usually specified within the macro).

  2. #2
    Steve
    Guest

    Re: Can macros output to a cell selected prior to running it?

    Hi Winnie

    Store the required address in a spare worksheet.
    Check your target address against your required address with If().

    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
    Boolean)

    Dim tAddr
    Dim reqAddr

    reqAddr = UCase(Worksheets("Sheet2").Range("A1").Value)
    tAddr = Target.Address

    If tAddr = reqAddr Then MsgBox "it works"

    End Sub


    HTH
    Steve

    "winnie" <[email protected]> wrote in message
    news:[email protected]...
    >I need to know if it is possible to run a macro from a cel that you specify
    > right before runing the macro (i.e. a variable cell rather than the same
    > constant cell which is usually specified within the macro).




  3. #3
    Dan Knight
    Guest

    RE: Can macros output to a cell selected prior to running it?

    Winnie;
    This may be overly simplified, but if by "a cell that you specify", you're
    thinking the activecell. Then in the macro simply refer to the Activecell
    property.

    Sub ()
    prev code....

    msgbox Activecell.address

    rest of code...
    end sub

    "winnie" wrote:

    > I need to know if it is possible to run a macro from a cel that you specify
    > right before runing the macro (i.e. a variable cell rather than the same
    > constant cell which is usually specified within the macro).


  4. #4
    Myrna Larson
    Guest

    Re: Can macros output to a cell selected prior to running it?

    If you mean the macro returns a value, change the code so it puts that value
    in the active cell, i.e.

    'calculate some value, x, here
    ActiveCell.Value = X

    On Thu, 17 Feb 2005 13:23:02 -0800, winnie <[email protected]>
    wrote:

    >I need to know if it is possible to run a macro from a cel that you specify
    >right before runing the macro (i.e. a variable cell rather than the same
    >constant cell which is usually specified within the macro).



+ 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