Disable a Function

hartless43

New Member
Joined
Dec 28, 2022
Messages
35
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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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