Forum Discussion

YeahMan's avatar
YeahMan
Brass Contributor
Jan 10, 2024
Solved

SUMIF on Numbers formatted as text

Hi,

I have something funky going on with my SUMIF statement. I have a table with a column of numeric codes which I have set the datatype to TEXT. My other table column has a count. I want to sum based on the first character of the code. E.g.,

MTCU Code                Number Entrants

410078
4760018
5010037

 

I am getting the following for the SUMIF calculation:

SUMIF(Programs[MTCU Code],"4*",Programs[Number Entrants]) = 0.

 

BUT if I add an 'x' to the end of each code:

MTCU Code                   Number Entrants

41007x8
47600x18
50100x37

 

I get the correct result:

SUMIF(Programs[MTCU Code],"4*",Programs[Number Entrants]) = 26.

I really don't want to add the 'x' as I need this field for XLOOKUPs.

 

Can anyone assist?

Thanks,

Sue

 

 

  • Hi again,
    Since I have 100's of these I found one way to mass insert an apostrophe is to use the VBA macro option found in this link: https://www.exceldemy.com/add-leading-apostrophe-in-excel/ since it was the only way I could get the prefix apostrophe that is hidden and is flagged as 'Number formatted as text' warning, which I want for XLOOKUPs.
    I set the data type back to General, ran the macro on the column, and voila, the SUMIF works.

    Thanks to everyone for their help
    Sue

Resources