• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • SALE 20% Off All Courses
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Logout
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Excel Wildcard Quirk Solved

You are here: Home / Excel Formulas / Excel Wildcard Quirk Solved
Excel Wildcard Quirk Solved
December 12, 2012 by Mynda Treacy

Last week I wrote about using less than and greater than operators with letters like this:

=COUNTIF(grade,"<B*")

Here’s the post.

Whilst playing around with different formulas I noticed that wildcards were not behaving as I would expect.

For example using the data below with cells A2:A13 named ‘grade’:

Excel Wildcards

Formula:

=COUNTIF(grade,"<B")

=2 which is counting the two A grades.

And this formula:

=COUNTIF(grade,"<B*")

=6 which is counting the A and B grades.

But this formula:

=COUNTIF(grade,">B*")

=6 which is the two C grades + two D grades + two E grades, but it doesn’t include the four B grades.

I was puzzled because with less than =COUNTIF(grade,"<B*") it included B grades, but with greater than =COUNTIF(grade,">B*") it didn’t include B grades.

The wildcard didn’t seem to be working consistently.

And the reason is this; sometimes1 when we use greater than or less than operators to test strings the asterisk is not considered a wildcard, it’s simply text, and as text it has a character value of 42.

We can see its character value in the Insert Symbol dialog box:

Excel Wildcards

We can also see that B has a character value of 66:

Excel Wildcards

These examples best illustrate what is happening behind the scenes:

Excel Wildcards

Note: Excel is testing the first character value, then the second character value and so on. It isn’t giving B* a value of 6,642 (six thousand, six hundred and forty-two).

1.Earlier I said "sometimes when we use greater than or less than operators to test strings the asterisk is not considered a wildcard", asterisks used like this; =COUNTIF(grade,"<>B*") where <> is not equal to, or this; =COUNTIF(grade,"=B*") are treated as wildcards.

It’s only with these operator arrangements that the asterisk is treated as text:

>=

<=

>

<

A big thank you to Roberto Mensa for explaining this quirk.

If you liked this please share it by using the buttons below to Like it on Facebook, Tweet about it on Twitter, share it on Google+ or LinkedIn, or just leave a comment thanking Roberto.

Excel Wildcard Quirk Solved

More Excel Formulas Posts

top excel functions for data analysts

Top Excel Functions for Data Analysts

Must know Excel Functions for Data Analysts and what functions you don’t have to waste time learning and why.
excel advanced formula environment

Excel Advanced Formula Environment

Excel Advanced Formula Environment is a long awaited, new improved way to write, name and store Excel formulas.
Pro Excel Formula Writing Tips

Pro Excel Formula Writing Tips

Must know Excel formula writing tips, tricks and tools to make you an Excel formula ninja, including a new formula editor.
excel shaping arrays

New Array Shaping Excel Functions

The Excel Shaping Array Functions makes it easier than ever to reshape arrays and ranges using these purpose built functions
excel nested if functions what not to do

Excel IF Formulas and What Not To Do

Excel IF formulas can get out of hand when you nest too many IFs. Not only do they become unwieldy they’re difficult for anyone to understand
excel image function

Excel IMAGE Function

The Excel IMAGE Function enables you to embed images in a cell using a formula. It supports BMP, JPG/JPEG, GIF, TIFF, PNG, ICO, and WEBP files

Excel VSTACK and HSTACK Functions

New Excel VSTACK and HSTACK functions makes combining arrays of cells easy and with some clever tricks we can extend their capabilities.
identify overlapping dates and times in excel

Identify overlapping dates and times in Excel

How to identify overlapping dates and times in Excel with a formula that checks a range of cells. Works with Dates and Times.
New Excel Text Functions

TEXTSPLIT, TEXTBEFORE and TEXTAFTER Functions

TEXTAFTER, TEXTBEFORE and TEXTSPLIT are exciting new Excel Text functions. They’re fairly self-explanatory, however TEXTSPLIT has some cool features.

Top 10 Intermediate Excel Functions

Take your Excel skills to the next level with this top 10 intermediate Excel functions. These are must know functions for all Excel users.




Category: Excel Formulas
Previous Post:Excel COUNTIF Using Text CriteriaExcel COUNTIF Using Text Criteria
Next Post:Merry Christmas 2012 and Happy New Year 2013Merry Christmas 2012 and Happy New Year 2013

Reader Interactions

Comments

  1. salah khalid

    January 13, 2013 at 11:09 pm

    Thank you very much, this is very peculiar

    Reply
  2. imran qaisar

    December 24, 2012 at 9:14 pm

    i would like to share exell ideas and also get the other

    Reply
  3. Ravi Xavier

    December 13, 2012 at 2:01 pm

    Thank you very much, this is very peculiar.

    Reply
    • Mynda Treacy

      December 13, 2012 at 8:29 pm

      You’re welcome, Ravi 🙂

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Current ye@r *

Leave this field empty

Sidebar

More results...

Course Sale

mynda treacy microsoft mvpHi, I'm Mynda Treacy and I run MOTH with my husband, Phil. Through our blog, webinars, YouTube channel and courses we hope we can help you learn Excel, Power Pivot and DAX, Power Query, Power BI, and Excel Dashboards.

Subscribe to Our Newsletter

Receive weekly tutorials on Excel, Power Query, Power Pivot, Power BI and More.

We respect your email privacy

Guides and Resources

  • Excel Keyboard Shortcuts
  • Excel Functions
  • Excel Formulas
  • Excel Custom Number Formatting
  • ALT Codes
  • Pivot Tables
  • VLOOKUP
  • VBA
  • Excel Userforms
  • Free Downloads

239 Excel Keyboard Shortcuts

Download Free PDF

Free Webinars

Excel Dashboards Webinar

Watch our free webinars and learn to create Interactive Dashboard Reports in Excel or Power BI

Click Here to Watch Now

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
trustpilot excellent rating
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk – For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved

Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.