• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help.. VBA code does not autorun

waseem

New Member
Dear VBA Gurus

Years ago I saw a post on this forum wherein if you click within a particular range of cells, the value in the selected cell is produced in a destination cell. For that I used following code:

>>> use code - tags <<<
Code:
Private Sub Macro1()
    If Not Application.Intersect(ActiveCell, [Input]) Is Nothing Then
        [Output] = ActiveCell.Value
        End If
End Sub
"Input" is name of a range if cells and "Output" is a cell name where I am obtaining the output as text in the selected cell.

The above code is running well. However, it runs only when I run the macro manually. All I need is to ensure that as soon as I click on one of the input cells, the value in the selected cell should be reproduced in the output cell without manually running the code. Appreciate someone's help.

Cheers
 
Last edited by a moderator:

waseem

New Member
Thank you Logit a lot for your prompt response. Actually I am not a VBA person so would appreciate if you could elaborate a bit about what is "MyMacro". It didnt work for me somehow.

Cheers
 

waseem

New Member
Just figured it out I wrote first line as

Code:
Private Sub Test ()
Now changed it to following and it worked.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Many thanks though for your support
 
Top