+ Reply to Thread
Results 1 to 8 of 8

Help Need with Macro to filter based on a value & to return values

  1. #1
    Registered User
    Join Date
    07-09-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    14

    Exclamation Help Need with Macro to filter based on a value & to return values

    Hi Friends,

    Need help in Excel, I really don't know how to solve this problem.

    I have attached a sample worksheet. Input is in Sheet1 & Output expected in Sheet2

    Conditions/Steps:
    1. Filter with column B (Pass)
    2. with the filtered list(Only pass list), check in column C(Comments),
    & Output the following into a new sheet.
    In the comments,
    List the number of rows that contains 90 in column 90 & above
    List the number of rews that contains 95 in column 90 above and so on"

    Any help is really appreciated.. Manually doing this work is really hard for me. it takes a lot of time..
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Help Need with Macro to filter based on a value & to return values

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-16-2014
    Location
    United States
    MS-Off Ver
    2010
    Posts
    204

    Re: Help Need with Macro to filter based on a value & to return values

    Try this:

    Sub rr()
    Dim iVal, iVal1, iVal2, iVal3 As Integer
    iVal = Application.WorksheetFunction.CountIf(Range("C1:C10000"), "*70")
    iVal1 = Application.WorksheetFunction.CountIf(Range("C1:C10000"), "*80")
    iVal2 = Application.WorksheetFunction.CountIf(Range("C1:C10000"), "*90")
    iVal3 = Application.WorksheetFunction.CountIf(Range("C1:C10000"), "*95")
    Range("D1") = "70 & above" 'output in Range D
    Range("D2") = "80 & above" 'output in Range D
    Range("D3") = "90 & above" 'output in Range D
    Range("D4") = "95 & above" 'output in Range D
    Range("E1") = iVal 'output in Range E
    Range("E2") = iVal1 'output in Range E
    Range("E3") = iVal2 'output in Range E
    Range("E4") = iVal3 'output in Range E


    ' set the range to display the output

    Cells.AutoFilter

    End Sub

  4. #4
    Registered User
    Join Date
    07-09-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    14

    Re: Help Need with Macro to filter based on a value & to return values

    Hi John,

    Thank you very much for your help.. It works exactly how i wanted.

    One more thing, instead of counting number, if i need to count for a wildcard text like "ansdhkha", what should i do?

    Many Thanks
    Quote Originally Posted by JOHN H. DAVIS View Post
    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-09-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    14

    Re: Help Need with Macro to filter based on a value & to return values

    Hello ExcelHelpSeeker,

    Thank you very much for your response.

    But, initially , i need the excel to be filtered based on "Pass" condition in column B.

    Can u pls look into it?

    Thanks again.
    Quote Originally Posted by excelhelpseeker View Post
    Try this:

    Sub rr()
    Dim iVal, iVal1, iVal2, iVal3 As Integer
    iVal = Application.WorksheetFunction.CountIf(Range("C1:C10000"), "*70")
    iVal1 = Application.WorksheetFunction.CountIf(Range("C1:C10000"), "*80")
    iVal2 = Application.WorksheetFunction.CountIf(Range("C1:C10000"), "*90")
    iVal3 = Application.WorksheetFunction.CountIf(Range("C1:C10000"), "*95")
    Range("D1") = "70 & above" 'output in Range D
    Range("D2") = "80 & above" 'output in Range D
    Range("D3") = "90 & above" 'output in Range D
    Range("D4") = "95 & above" 'output in Range D
    Range("E1") = iVal 'output in Range E
    Range("E2") = iVal1 'output in Range E
    Range("E3") = iVal2 'output in Range E
    Range("E4") = iVal3 'output in Range E


    ' set the range to display the output

    Cells.AutoFilter

    End Sub

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Help Need with Macro to filter based on a value & to return values

    Maybe use if and like together?

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-09-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    14

    Re: Help Need with Macro to filter based on a value & to return values

    Thanks Again John.. You saved my day...!!!

    Quote Originally Posted by JOHN H. DAVIS View Post
    Maybe use if and like together?

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Help Need with Macro to filter based on a value & to return values

    You're welcome. Glad to help out.

+ 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. vba macro filter based on a array of cells with text and number values
    By daviddg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2014, 04:39 AM
  2. Replies: 5
    Last Post: 12-19-2013, 06:58 AM
  3. Replies: 4
    Last Post: 02-10-2013, 01:44 AM
  4. [SOLVED] Edit Recorded Macro to filter column with about 200k rows based on a list of values.
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-19-2012, 03:35 AM
  5. Return Unique Text Values without Advanced Filter
    By nicknick5219 in forum Excel General
    Replies: 11
    Last Post: 05-21-2009, 10:15 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