Specific cells activate Macro

soulpeep

New Member
Joined
Jun 12, 2011
Messages
5
Hi all;

I have some coding in my worksheet that changes the background/text color of a cell, based on the text within it, selected from six options on a dropdown menu.

I'd like to program it as a specific macro that only runs when I change data in the key cells, as right now, every time you perform an action, anywhere in the sheet, the code runs and you can't undo anything.

Anyone know of a way to activate the macro with the drop down menu selection? Or only have the code run when data is changed within those particular columns? (It doesn't matter if you can't undo THOSE changes).

Thanks!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Well, I'm sure you have
Worksheet_Change (ByVal Target As Range) event embedded in your code right now.

If you want a macro to be fired when there's a specific change in column A.
You can use this snippet of code:
Code:
If Target.Column = 1 Then
   'Your code
End If

So, what the event does is, It gives you the changed cell reference as Target.
All you have to do is check if the target's column is what you want and execute the code accordingly.

As for activating the macro with the drop down menu.
You can do it by dropDownMenu_Change() event where you could double click your dropDownMenu in design mode or you can do it by checking its values at a click of a button.
 
Upvote 0
Thanks for the quick reply.

I used the target column function you described and had it call up my old code (which I moved off the worksheet into a module).

I am completely learning by doing here, and that worked great.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,544
Members
452,925
Latest member
duyvmex

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