Disable a Function

hartless43

New Member
Joined
Dec 28, 2022
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Here is a Function given to me by FLUFF (on another forum) and would like to be able to disable it based on a cell value because I am using an Algorithm that creates a Sudoku Solution in about 10-15 seconds but with a function that is calculating faster than a speeding bullet it takes a very, very, forever for the Algorithm to create a solution. I am currently using a YES or NO to not show the mistakes.
Code:
Function CountByFontColor(Data As Range, CellRefColor As Range)

    Dim CellColor As Long
    Dim CurrentCell As Range
    Dim CountFont As Long
Application.Volatile
CountFont = 0
CellColor = CellRefColor.Font.ColorIndex
    For Each CurrentCell In Data
If CellColor = Evaluate("CFColour(" & CurrentCell.Address & ")") Then
    CountCell = CountCell + 1
End If
Next CurrentCell
    CountByFontColor = CountCell

End Function
Function CFColour(Cl As Range) As Double
   CFColour = Cl.DisplayFormat.Font.ColorIndex
End Function
'writen by Fluff13 Excel Forum Guru

I would like to have a statement like this: If Range("W14") = "NO" then End Function
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try adding this near the start of the function
VBA Code:
If UCase(Range("W14").Value) = "NO" Then Exit Function
 
Upvote 0
Solution
You're welcome. Thanks for the confirmation. :)
 
Upvote 0
Thanks, Peter, put that in and it worked.
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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