how can i run the macro without the need of button

P

programergirl

we are working on project that need the use of macro in excel. we have
written the code and it wok fine the next step is that required from us is to
get these macros to run automaticcally rather than manually .that instead of
user clicking on the button to activate the macro we want the macro run all
the time .just like if there is any event attached to the cells that anable
the macro to run every time the user enter something for example in
validation funtion it give is warning directly after giving illegal value .
we want it to run just like that but with our macro or specifacations
can any one help us plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
thanks in advance
 
G

Gary''s Student

Let's say you already have a macro like:

Sub programmer_girl()
MsgBox ("Hello World")
End Sub

in a standard module. In Worksheet code, put the following module:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A1"), Target) Is Nothing Then
Exit Sub
End If
Call programmer_girl
End Sub

Anytime data is entered in cell A1, programmer_girl will be called.
 
P

programergirl

hey
thanks for replying me
but i did exactly what u told me too
somehow it didnt work :(
i have no idea what is the problem caues my macro work with button or when i
run it
but the module u give it to me didnt run the macro
can u help me find out why i really need it for my project
thanks again

programergirl
 
G

Gary''s Student

Most of the time these things don't work is because the codes are in places
Excel can't find. You code needs to be public, in a standard module, not
Button code:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window


Then in the Worksheet:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste this stuff in and close the VBE window:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A1"), Target) Is Nothing Then
Exit Sub
End If
Call programmer_girl
End Sub

You need only enter data in cell A1 to activate the macros.
 
P

programergirl

oh man thank you very much its work
u really make my day
thanks alot
i really would like to take ur email so if i needed anything i can be
contact directly with u thats ofcourse if u dont mind

programergirl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top