• 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
    • 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
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • 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
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Count - Based on cells format|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / Count - Based on cells format|General Excel Questions & Answers|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumGeneral Excel Questions & Answe…Count - Based on cells format
sp_PrintTopic sp_TopicIcon
Count - Based on cells format
Avatar
Rafi
Chennai
Member
Members
Level 0
Forum Posts: 9
Member Since:
July 19, 2019
sp_UserOfflineSmall Offline
1
January 31, 2020 - 3:13 am
sp_Permalink sp_Print

Hi,

I have a situation where i need to count based on format of the cells like "General format" or "Number format"

Is there any formula to count the data based on "General or Number format"?? Attached Excel file for your reference.

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
2
January 31, 2020 - 5:29 am
sp_Permalink sp_Print

You need the Cell function

Try this blog by Mynda

https://www.myonlinetraininghu.....l-function

You will need to reference back to the blog as the output are kind of codes, but they will tell you the cell formatting and you can then countif

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 615
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
3
January 31, 2020 - 8:29 am
sp_Permalink sp_Print

In my opinion, you'd be better off rethinking your approach. Formatting should reflect data, not be used as data.

Avatar
Rafi
Chennai
Member
Members
Level 0
Forum Posts: 9
Member Since:
July 19, 2019
sp_UserOfflineSmall Offline
4
February 1, 2020 - 3:59 am
sp_Permalink sp_Print sp_EditHistory

Hi Purfleet,

Your link taught me a new things. First of all thanks a lot.

You are right, if i insert new column to get cell format for each cell, then only i can count.

Is there any other option to count directly with single column. If any anyone know the answer, please help me. Attached file for your reference.

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
5
February 1, 2020 - 7:50 am
sp_Permalink sp_Print

I actually do agree with Velouria - you really shouldnt be calculating anything on a cell format.

To my knowledge you cant use ranges with the Cell & Address function, If you have to count formats i would used the formula above with the extra column and then either delete or hide the column after use.

The other possiblity is VBA, the below code would count the Number format and general format, but would need to add more ifs if you want anything else.

Sub cFormat()

Dim r As Range
Dim C As Range
Dim nf As Integer
Dim gf As Integer

nf = 0
gf = 0

Set r = Range("f4:f8")

For Each C In r
Debug.Print C.DisplayFormat.NumberFormat
If C.DisplayFormat.NumberFormat = "#,##0.00" Then
nf = nf + 1
End If
If C.DisplayFormat.NumberFormat = "General" Then
gf = gf + 1
End If

Next C

MsgBox "Number format = " & nf & " General Format = " & gf

End Sub

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
6
February 2, 2020 - 1:35 am
sp_Permalink sp_Print

Hi Rafi

Just wondering why do you want to count based on cell format?

What is the practical use?

Sunny

Avatar
Rafi
Chennai
Member
Members
Level 0
Forum Posts: 9
Member Since:
July 19, 2019
sp_UserOfflineSmall Offline
7
February 2, 2020 - 7:02 am
sp_Permalink sp_Print sp_EditHistory

Hi Sunnykow,

Open the attached file. My requirement is in "column I". This is my Journal entry (Finance term). Each and every day i need to fill the data and upload into SAP tool.

If i have any value in Number format in "Column I" , SAP tool will throw me the run time error. It means that particular SAP T-code will not accept Number format values.

If you check in Row 1 (Green color cells), i have used conditional formatting to find the missing data with subtotal-count. Similarly, I need a check for this "column I" before uploading the file whether my "column I" contains any number format or not.

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
8
February 2, 2020 - 8:18 am
sp_Permalink sp_Print

Hi Rafi

Rather than find the cells that can error wouldn't it just be better & more reliable to format the entire column as general as a matter of course? Just click on column I and change all to general?

I understand why you are look for the cell type, i just wonder if you really need to

Purfleet

Avatar
Rafi
Chennai
Member
Members
Level 0
Forum Posts: 9
Member Since:
July 19, 2019
sp_UserOfflineSmall Offline
9
February 2, 2020 - 11:32 pm
sp_Permalink sp_Print

Hi Purfleet,

Just click on column I and change all to general? I know this very well.

I need a check to find the number format cells. Take your time and tell me if you find.

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
10
February 3, 2020 - 12:18 am
sp_Permalink sp_Print

I have to agree with Purfleet.

No need to check.

Just change the entire column to the required format.

Avatar
Michael Goodwin

New Member
Members
Level 0
Forum Posts: 1
Member Since:
January 30, 2023
sp_UserOfflineSmall Offline
11
January 30, 2023 - 9:55 pm
sp_Permalink sp_Print

@Velouria, @Purfleet and the like,

I'm not sure saying 'rethink your approach coz using formatting to calculate is bad' is helpful. And "you really shouldnt be calculating anything on a cell format." How come you shouldn't? If it serves your use, go for it; there is nothing wrong with it.

Take this case. I am putting down figures for accomodation in a spreadsheet and I track what's paid by colouring unpaid red and paid green. I want the total cell to calculate all the red cells so I know how much is outstanding.

So you see @SunnyKow there are practical uses lol.

Thanks for the info guys

Take it easy

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
12
January 31, 2023 - 3:35 pm
sp_Permalink sp_Print sp_EditHistory

Hi Michael

Thanks for your feedback.

I did not say that there is no practical use in counting/summing cells with colors but there are some restrictions.

You can see the details here Calculating the Count, Sum and Average in Colored Cells

I too use a lot of colors in my reports/error-refreshing-connections-dashboard-reports (even though is is frowned upon by many) since sometimes it is part of the requirement.

In Rafi's case he wanted to count the type of cell formatting (not colors) and we only suggested other alternatives for him to explore. The final choice is his.

In your scenario if I want to track paid/unpaid amount, I would prefer to have helper columns to indicate their status.

It will allow me to analyze the data in a Pivot Table and display them on a dashboard.

There are no wrong or right ways to do what we want. It's just a matter of preference.

Happy Excelling

Cheers

Sunny

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 615
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
13
January 31, 2023 - 7:29 pm
sp_Permalink sp_Print

"I'm not sure saying 'rethink your approach coz using formatting to calculate is bad' is helpful. And "you really shouldnt be calculating anything on a cell format." How come you shouldn't? If it serves your use, go for it; there is nothing wrong with it."

Do you think it's more helpful to encourage someone down a path that you know from experience will cause them problems, or to suggest they adopt a different approach from the outset? Excel is not designed to calculate based on cell formats and anything you do to try and make it do so will be a convoluted workaround that probably won't work reliably since changing cell formats doesn't trigger any events you can use to force a recalculation. There is almost always a better way to set things up so that you can work with the software, not against it.

Anything I say in this, or any other, forum is simply my advice. Nobody has to take it. 🙂

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Mynda Treacy, Shanna Henseler, Stacy Culpepper
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27237

 

Member Stats:
Guest Posters: 49
Members: 31889
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

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
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

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.