run the same macro, when a no. is entered in diff. cells

martha555

New Member
Joined
Jun 28, 2005
Messages
41
hi, :p
I want to perform a set of actions(macro), when a particular value is entered in a cell. For e.g., I have a macro named "m1'. When the user enters 1 in cell A1, I want to run the macro"m1". Again, if the user enters 2 in cell A2, again I want to run the same macro. Similarly, I want to keep running the macro "m1" as long as the user enters a serial number in column A in consecutive rows. How do I go about it. Please help.
 

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Hello martha,

You would use a change event using VBA. Can you describe that last part for us a little more? ..as long as the user enters a serial number in column A in consecutive rows. Perhaps some examples of your data?
 

martha555

New Member
Joined
Jun 28, 2005
Messages
41
thanx for the response, I'll explain. Suppose I have an excel sheet as follows:
A B C


Now when I enter 1 in cell "A!", I want to run macro "m1". After its execution, now if I enter 2 in cell "A2", I want to run macro "m1" again. Similarly, if I enter the value 3 in cell "A3", again I want to run macro "m1". As long as I enter a number serially in the cells "A#", I want to run macro "m1", after I have entered the number. How do I go about it.
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
So basically, if the cell in column A has a value entered in it, and it's numeric, and that value matches the row number, and it's sequential to all other numbers before it, then run the macro. Is that right?
 

martha555

New Member
Joined
Jun 28, 2005
Messages
41
Bang on, except that the value need'nt match the row number, because I will actually be starting my series from cell "A5". That is, cell "A5" will have the value 1, cell "A6" the value 2 and so on.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,017
Messages
5,569,640
Members
412,284
Latest member
Daibear
Top