• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro not working in excel 2007

Arun Mani A

New Member
Dear All

the below macro not working in excel 2007, please help

Code:
Function zCountif(rng, cell)

Application.Volatile

Set zRange = rng
Set zCell = cell

zValue = cell.Value
zFontColor = zCell.Font.Color
zCellColor = zCell.Interior.Color

zCountif = 0

On Error Resume Next
For Each cell In zRange
If cell.Value = zValue Then
If cell.Font.Color = zFontColor Then
If cell.Interior.Color = zCellColor Then
zCountif = zCountif + 1
End If
End If
End If
Next

On Error GoTo 0

End Function
-------------------------------------------------------------------------------------------
Edited by Mod: Placed code inside tag.
 
Last edited by a moderator:
Hi Arun Mani A

This is a function, so it must be called in procedures, or triggered with events.
In this case it also requires 2 inputs: a range and a cell.
How are you using this code?
As a stand alone code, I'm afraid it won't do much.


G.
 
Also as side note, note that in Excel 2007 there isn't method available to read Conditional Format applied color.

While 2010 and later has DisplayFormat method, it does not work when used in UDF (outside of code/module).
https://chandoo.org/forum/threads/count-color-cells-in-conditional-formating.32008/#post-189994

When posting asking for help, please indicate "HOW" it's not working. Otherwise, we'll be stabbing in the dark as to your situation.

As well, please use CODE tag when posing codes. I have edited the post this time.
upload_2018-1-5_8-11-1.png
 
Also as side note, note that in Excel 2007 there isn't method available to read Conditional Format applied color.

While 2010 and later has DisplayFormat method, it does not work when used in UDF (outside of code/module).
https://chandoo.org/forum/threads/count-color-cells-in-conditional-formating.32008/#post-189994

When posting asking for help, please indicate "HOW" it's not working. Otherwise, we'll be stabbing in the dark as to your situation.

As well, please use CODE tag when posing codes. I have edited the post this time.
View attachment 48605
Didn't know about that method. Great insight.
 
Sorry for late reply Chihiro, the problem is i have to go to fx (formula) and then press F2 key then it gets updated.

If i go to the formula function, value error comes and then if i press F2 then value populates, i am having this formula in 300 + cells, every time i have to do this.

Please help out.

Regards
 
Back
Top