Activating a macro with a cell value

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try this:
Mary is the name of the Macro you want to run.
Modify this script to your liking
When you enter "Mary" into Range A1 the Macro will run.

To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Cells(1, 1).Value = "Mary" Then
Cells(1, 1).Value = ""
Call Mary
End If
End Sub
 
Last edited:
Upvote 0
So i have tried this code, and its not working. I want to change the value in Cell C17 based on the value in C8
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C8").Value = "YES" Then
Range("C17").ClearContents
Range("C17").Value = "=IF(AND(C6=0,C7=0),0,IF(SUM(C6*C10)+SUM(C7*75)+SUM(E18:E19)<220,220,SUM(C6*C10)+SUM(C7*75)+SUM(E18:E19)))"


End If


End Sub
 
Upvote 0

Forum statistics

Threads
1,203,399
Messages
6,055,175
Members
444,767
Latest member
bryandaniel5

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