Reputation: 940
I have this vba code which starts and runs on itself everytime data updated.
Function CM(r As Range, c As Range, d As Range) As Integer
Dim lR As Long
CM = 0
For lR = d.Rows.Count To 2 Step -1
If Application.CountIf(d.Rows(lR), r) > 0 And Application.CountIf(d.Rows(lR - 1), c) > 0 Then CM = CM + 1
Next lR
End Function
Is it possible to make it start manually going through F8, selecting the macro and start it? I am not sure why it is made this way. thanks.
Upvotes: 0
Views: 153
Reputation: 7117
https://www.tutorialspoint.com/vba/vba_functions.htm
The only reason I am writing this as an answer is to show you this:
You can call functions form the immediate windows to test their outputs. This is a very powerful tool and i suggest you play around with it to get familiar with it. I tend to use this many times throughout the day due to some of the Access applications i have to support.
To view the immediate window hit Control+G.
* added note * If you need to test your function remember the input parameters are ranges so each pass value should look something like:
ThisWorkbook.Sheets("Yoursheetname").Range("yourrange")
I hope this helps you quite a bit!
Upvotes: 1