• 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.

active cell to run macro

Hi, kalpeshpatel!

It isn't very clear what do you want to do, is it running a macro when something entered in A1? Please explain.

Regards!
 
@Kalpesh,


1. Press Alt+F11 to get the VB Editor on the Screen.

2. Go to View Menu and Click on Project Explorer.

3. On the Left Hand side.... Double Click on Sheet1

4. Paste the below code...


Now everytime you click on Cell A5... you will get the message box... (change this to run your code)...


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$A$5" Then

MsgBox "You just clicked cell A5.... Now i will run"

End If

End Sub


~VijaySharma
 
Do you mean... when you click on cell A1... then lock the scroll area to A1:F10... and if any other cell is clicked then unlock the scroll area?


~VijaySharma
 
wow it is great


code will work perfect

thanks for help


it is possibel to active cell range e.g


cell active between a1:B10 range to run macro
 
Sure. You can do something like this:

[pre]
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Range("A1:B10"),Target) Is Nothing Then Exit Sub
MsgBox "You are in the target range.... Now i will run"
End Sub
[/pre]
 
Back
Top