Automatically run a routine

hartless43

New Member
Joined
Dec 28, 2022
Messages
24
Office Version
  1. 365
Platform
  1. Windows
This will be easy for someone (not me) but the below Macro is run by a Macro Button. I would like for it to run automatically as soon as cell "G11" is 81. I think it can be done via Function or a WorkSheet_Change but I ain't that good at creating a function or whatever is needed to make it work. This is a Sudoku thing.


VBA Code:
Sub ShowMistakes()
If Range("G11") = 81 Then
Range("W13") = "Yes"      '/This is set to "NO" while playing Sudoku and Mistakes are not shown until "G11" is 81
End If
End Sub

Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
try
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Range("G11") = 81 Then
     Range("W13") = "yes"
Else
     Range("W13") = ""
End If

Application.EnableEvents = True
End Sub
Usually I advocate an error handler when cycling application properties but didn't include one in this simple case.
 
Upvote 1
Solution
You're welcome & thanks for the recognition.
 
Upvote 0

Forum statistics

Threads
1,221,521
Messages
6,160,301
Members
451,637
Latest member
hvp2262

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