Count Occurences of a Cell If It's Less Than

matthewlouis

Active Member
Joined
Mar 28, 2014
Messages
374
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
In my probability analysis spreadsheet, I have a single cell (E10) that contains a %. My goal is to create a counter where, on a mouse click, it will count the number of times cell E10 <=80%.

If I do 30 clicks, 40 clicks, just a simple set of iterations . . . I would like to see the cell count the times those clicks were less <=80%.

What would the formula look like for that?

Thanks in advance!
 
Whilst in the Editor press Ctrl G and the immediate window should open up.
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Thanks, Fluff!!

OK, James, as you can see, there is nothing in the immediate window.
 

Attachments

  • 2021 Screenshot for ALGO.png
    2021 Screenshot for ALGO.png
    56.7 KB · Views: 3
Upvote 0
That debug.print statement in the code is putting a count to 100 in the immediate window, followed by the contents of the cell. It looks like the macro just isn't running. It could be a macro security issue. Check under the developers tab, Macro Security. Sometimes it is necessary to restart excel.
 
Upvote 0
That debug.print statement in the code is putting a count to 100 in the immediate window, followed by the contents of the cell. It looks like the macro just isn't running. It could be a macro security issue. Check under the developers tab, Macro Security. Sometimes it is necessary to restart excel.
OK< do I have the right selection here? I don;t use macros (as you can tell) so maybe I don't have the right box checked (?) When I open the sheet, it does not ask me if I want to run a macro, it just opens.
 

Attachments

  • macros.png
    macros.png
    24.3 KB · Views: 3
Upvote 0
That debug.print statement in the code is putting a count to 100 in the immediate window, followed by the contents of the cell. It looks like the macro just isn't running. It could be a macro security issue. Check under the developers tab, Macro Security. Sometimes it is necessary to restart excel.

I changed the settings as you can see to enable, closed the worksheet, reopened, and it still isn't running. In my ribbon at the top, under the Develepor tab, the macro button has a yield sign next it (?)
 

Attachments

  • macro 2.png
    macro 2.png
    27.4 KB · Views: 3
Upvote 0
I tend to have mine on the second one (disable with notification) and then I enable the macros in a pop up window when I load the file. You might close excel and reopen, not just the sheet.
 
Upvote 0
I tend to have mine on the second one (disable with notification) and then I enable the macros in a pop up window when I load the file. You might close excel and reopen, not just the sheet.
OK, did that, close Excel, reopened, and algo still isn't running. I am not getting any message that asks me if I want to enable a macro (?)

The algo just isn't calculating, only counting. What's weird is I see calculating at the bottom of the sheet, very fast, but none of my numbers are changing, thus no occurrences.
 
Upvote 0
And the immediate window in VBA doesn't have any 1-100 in it?... Did you save the file as an .xlsm file? you can put a msgbox function in there, that will give you a pop up if it's working.

Sub clicky()
For t = 1 To 100
Application.Calculate
Range("G10").Value = Range("G10").Value + 1
If Range("E10").Value <= 0.8 Then Range("G11").Value = Range("G11").Value + 1
Debug.Print t & ":" & Range("E10")
MsgBox t
Next t
End Sub

1625751208740.png
 
Upvote 0
I will update the algo with what you just posted . . . I have saved it as a macro-enabled workbook. Same thing as .xlms ?
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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