+ Reply to Thread
Results 1 to 10 of 10

Calculating percentage using VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    12-26-2016
    Location
    Dubai
    MS-Off Ver
    2013
    Posts
    31

    Calculating percentage using VBA

    I need to calculate the percentage for the below code.

    Cell AE43 gives the total count out.

    Cell AE51 gives valid count.

    Cell AE53 should hold the % for this.

    How do i implement this sub for multiple cells without creating separate sub for each cells?

    Sub WBR()
    Dim Count1Criteria As Variant
    Dim Count3Criteria As Variant
    Dim test As Variant
    Dim wf As WorksheetFunction
    Set wf = Application.WorksheetFunction
    
    Filter1InSummary = Array(Array("AE4", "Latency", "O:O", "Pass"), _
                             Array("AE51", "TT", "G:G", "Yes"), _
                             Array("AE52", "TT", "G:G", "No"), _
                             Array("AE61", "Reactive", "R:R", "Item"))
    
    Filter3InSummary = Array(Array("AE43", "TT", "I:I", "<>Duplicate TT", _
                                                 "G:G", "<>Not Tested", _
                                                 "U:U", "Item"))
    For Each test In Filter3InSummary
        With Worksheets(test(1))
            Range(test(0)) = wf.CountIfs(.Range(test(2)), test(3), _
                                         .Range(test(4)), test(5), _
                                         .Range(test(6)), test(7))
        End With
        Next

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,956

    Re: Calculating percentage using VBA

    Why not just use a regular formula, copied down?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    12-26-2016
    Location
    Dubai
    MS-Off Ver
    2013
    Posts
    31

    Re: Calculating percentage using VBA

    I know that's the simplest way. But I need this to be done in VBA

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,956

    Re: Calculating percentage using VBA

    OK, can I ask why?

  5. #5
    Registered User
    Join Date
    12-26-2016
    Location
    Dubai
    MS-Off Ver
    2013
    Posts
    31

    Re: Calculating percentage using VBA

    We have a project where we are not supposed to use formulas in the excel, instead get this done in VBA

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,956

    Re: Calculating percentage using VBA

    So, kinda homework?
    lol

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,956

    Re: Calculating percentage using VBA

    So, kinda homework?
    lol

  8. #8
    Registered User
    Join Date
    12-26-2016
    Location
    Dubai
    MS-Off Ver
    2013
    Posts
    31

    Re: Calculating percentage using VBA

    No, lol. This is small part of a larger VBA code. Using formula for this task alone will not be good..

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,956

    Re: Calculating percentage using VBA

    OK thanks for the feedback

  10. #10
    Registered User
    Join Date
    12-26-2016
    Location
    Dubai
    MS-Off Ver
    2013
    Posts
    31

    Re: Calculating percentage using VBA

    Any help here?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Calculating a Percentage of a Percentage
    By tpedry in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-27-2014, 03:44 PM
  2. calculating percentage of percentage
    By zinneken in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-10-2013, 10:12 AM
  3. [SOLVED] Calculating a percentage with the end percentage in mind
    By Shadowshady in forum Excel General
    Replies: 2
    Last Post: 06-17-2006, 04:45 AM
  4. [SOLVED] Calculating Percentage
    By mconnolly in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 04:05 PM
  5. Calculating Percentage
    By mconnolly in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  6. [SOLVED] Calculating Percentage
    By mconnolly in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  7. [SOLVED] Calculating Percentage
    By מיכאל (מיקי) אבידן in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  8. [SOLVED] Calculating Percentage
    By mconnolly in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1