Share via

Problem using Countif after extracting data with the Mid function

Anonymous
2011-06-29T02:40:19+00:00

Column 1 Col 2

=MID(K95,6,2) 2

=MID(K96,6,2) 3

=MID(K97,6,2) 2

=MID(K100,6,2) 6

=MID(K101,6,2) 6

=MID(K103,6,2) 3

=MID(K104,6,2) 3

=COUNTIF(Z95:Z104,"6") 2

=COUNTIF(Z93:Z104,"">=4) 0

When I use the mid function to extract a no from a cell that contains both txt and nos, whilst I can use then use the countif on the column to count an exact no as 6, I get the correct result, however if I use countif with >=4 as in the second example, I don't.  I know the cells in the extracted col 2 are recognized as txt and not nos even though only a no exists, any ideas, why =6 works but >=4 does not?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-06-29T05:23:52+00:00

By using MID() you're returning text, not numbers. One way to return numbers:

=--MID(K95,6,2)

Then your COUNTIF(Z93:Z104,">=4") will work

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

OssieMac 48,001 Reputation points Volunteer Moderator
2011-06-29T05:06:09+00:00

any ideas, why =6 works but >=4 does not?

I tested and it sure did not work but I can't answer why. However, as a work around, is practical in your project to modify the formulas with the mid functions like the following and then the countif will work because the cells will contain the numbers as numeric instead of text.

=VALUE(MID(K95,6,2))

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more