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.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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?
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,577
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top