Results 1 to 11 of 11

Thread: [RESOLVED] Excel Formula Needed

  1. #1

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Excel Formula Needed

    I always do things the easy way. If you ever wanted to use the number 2, then you'd have to recode all the statements to do it, which doesn't make sense.
    There might be an easier way, but I would just use a cell that is a flag to whether your number is there or not, and then count the numbers, and the flags.

    I did this, and formatted it as a percentage with 0 decimal places
    Attached Files Attached Files

  3. #3

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Excel Formula Needed

    How about just adding a filter? Then you could just count the rows. It would be dynamic too.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Excel Formula Needed

    Place the active cell in the column and one row above the row data to be filtered.
    Data > Filter > Autofilter. Then click on the combo box that appears and you get a choice of many options: filter by a particular unique
    content, Top 10, All, Custom, Sort Asc, Sor Desc, etc.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Excel Formula Needed

    I thought you wanted to do it programmatically. Adding a calculation column isn't a bad thing unless you are using all of them

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Excel Formula Needed

    You should use the COUNTIF() function for this. You can get it to count only the values which meet a certain criteria then use the COUNT() function to find the total number of cells in the range.
    1. Highlight the range of cells you want to include in your formula and go to Insert->Name call the range numbers.
    2. Find the cell where you want to calculate the percentage and enter the following formula.
      Code:
      =COUNTIF(numbers,1)/COUNT(numbers)
    3. Format the cell as a percentage type by right clicking and clicking Format Cells

    Have a look at the attachment to see the result.
    Attached Files Attached Files
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  9. #9

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Excel Formula Needed

    Quote Originally Posted by visualAd
    You should use the COUNTIF() function for this. You can get it to count only the values which meet a certain criteria then use the COUNT() function to find the total number of cells in the range.
    1. Highlight the range of cells you want to include in your formula and go to Insert->Name call the range numbers.
    2. Find the cell where you want to calculate the percentage and enter the following formula.
      Code:
      =COUNTIF(numbers,1)/COUNT(numbers)
    3. Format the cell as a percentage type by right clicking and clicking Format Cells

    Have a look at the attachment to see the result.
    How do I define "numbers"?

  10. #10
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Excel Formula Needed

    Its just an easier way of specifying a range of cells. Highlight the cells you want to include in the range and then goto Name->Define in the Insert menu. You should then get a dialog box which enables you to give the range a name.
    Attached Images Attached Images  
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  11. #11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width