How to start a makro

J

johnny

When I delete a name in a cell I have made a makro that is doing some
"cleening up". How can I make this makro start when the name is deleted? Or
do I really need a button to make the makro starting?
 
N

NoodNutt

G'day John

You could use the Worksheet_Change event.

Something like

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("YourRange")) Is Nothing Then
Application.Run "YourMacro"
End If
End Sub

("YourRange") can be multiple Cells ("A1" , "K20", Z1:Z100)

HTH
Mark.
 
M

MuppetMan

you need to put some code in the worksheet "CHANGE" event...

something like this -

Private Sub Worksheet_Change(ByVal Target As Range)

Call MY_MACRO 'where MY_MACRO is the name of your "Clean up" macro.

End Sub

This code MUST go in the worksheet_Change event for the actual sheet
you are working on.

Muppet Man.
 
J

johnny

I finally make the makro start and function in a way... But I want it to
start only when the value in the cell is deleted, how can I make that
happend?

MuppetMan skrev:
 
G

Gord Dibben

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And Target.Value = "" Then
macroname
End If
End Sub


Gord Dibben MS Excel MVP
 

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