+ Reply to Thread
Results 1 to 14 of 14

Macro to delete certain items then count remaining items #2

Hybrid View

elgato74 Macro to delete certain items... 12-21-2019, 01:18 PM
PCI Re: Macro to delete certain... 12-21-2019, 01:27 PM
elgato74 Re: Macro to delete certain... 12-21-2019, 01:30 PM
Marc L H, can be achieved as it... 12-21-2019, 01:43 PM
elgato74 Re: Macro to delete certain... 12-21-2019, 01:48 PM
Marc L First do not quote all... 12-21-2019, 01:53 PM
elgato74 Re: Macro to delete certain... 12-21-2019, 01:53 PM
Marc L Ok I won't waste time anymore... 12-21-2019, 01:56 PM
PCI Re: Macro to delete certain... 12-21-2019, 01:58 PM
elgato74 Re: Macro to delete certain... 12-21-2019, 02:04 PM
mikerickson Re: Macro to delete certain... 12-21-2019, 02:10 PM
PCI Re: Macro to delete certain... 12-21-2019, 02:13 PM
elgato74 Re: Macro to delete certain... 12-21-2019, 02:16 PM
PCI Re: Macro to delete certain... 12-21-2019, 02:26 PM
  1. #1
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    580

    Macro to delete certain items then count remaining items #2

    Dear All,

    please have a look at the attached file

    In column A, I have 30,000+ entries. You will notice that there are items with names and items with 3-Letter codes + suffix such as STO-1K, DTS-Pano and so on.

    I am trying to come up with a macro that does the following:

    1. Delete all cells with 3-Letter Codes + Suffix
    2. So that only names remain
    3. Count those, e.g. Pacino = 446 times


    I hope the attached file shows the mission...

    Thanks muchly!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Macro to delete certain items then count remaining items #2

    What about Macro to delete 3-Letter Codes + Suffix and a Pivot Table ...?
    If it is OK then is needed a header ...!
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    580

    Re: Macro to delete certain items then count remaining items #2

    sure, looking forward to your solution

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    H,

    can be achieved as it is without any header, I think first a while before posting any entry level code …

  5. #5
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    580

    Re: Macro to delete certain items then count remaining items #2

    Quote Originally Posted by Marc L View Post
    H,

    can be achieved as it is without any header, I think first a while before posting any entry level code …
    You wanna help or just be smartypants?

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation

    • First do not quote all previous post, that just clutters ! Thanks.

    • I do not understand your word but just well reading again my post this time
      you must understand it was first an advise it can be achieved as it is without any header and I'm thinking about it ‼

  7. #7
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    580

    Re: Macro to delete certain items then count remaining items #2

    Quote Originally Posted by Marc L View Post
    • First do not quote all previous post, that just clutter ! Thanks.

    • I do not understand your word but just well reading again my post this time
      you must understand it was first an advise it can be achieved without as it is without any header and I'm thinking about it ‼
    blah blah blah farewell dude

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow


    Ok I won't waste time anymore for an already existing easy fast way, good luck …

  9. #9
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Macro to delete certain items then count remaining items #2

    Here a possibility, but take care of the header
    Option Explicit
    
    
    Sub Treat()
    Dim I  As Integer, II  As Integer, LR As Integer
    Dim WkAr1
    Dim WkAr2
    
        LR = Cells(Rows.Count, 1).End(3).Row
        WkAr1 = Range(Cells(1, 1), Cells(LR, 1))
        ReDim WkAr2(1 To LR)
        For I = 1 To UBound(WkAr1, 1)
            If Not (Len(Split(WkAr1(I, 1), "-")(0)) = 3) Then
                II = II + 1
                WkAr2(II) = WkAr1(I, 1)
            End If
        
        Next I
        Cells(1, 1).Resize(LR, 1) = Application.Transpose(WkAr2)
        ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
    
    End Sub
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    580

    Re: Macro to delete certain items then count remaining items #2

    Wow, that looks great! Thank you. But pardon, how would I sort by "Count of Name" ?

  11. #11
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro to delete certain items then count remaining items #2

    To count the entries, you could use =COUNTIF(A:A, "*"&B1&"*). No need to eliminate the coded rows.

    But, I think that your sample results are off, I can only find one entry for "R8 V5 3P", cell A4, but your sample results list 4. (similar for "Holidays")
    If I am wrong, what are the other three cells that you consider to be matching "R8 V5 3P".
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Macro to delete certain items then count remaining items #2

    how would I sort by "Count of Name" ?
    Left click on a name to select name field
    Right click > Sort > Sort A to Z

    In a general manner see the use of Pivot Table, it is very useful

  13. #13
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    580

    Re: Macro to delete certain items then count remaining items #2

    Perfect, thank you and Cheers to the Alsace, Merry Xmas

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Macro to delete certain items then count remaining items #2

    You're welcome
    Merry Christmas to

+ 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] Macro to delete certain items then count remaining items
    By elgato74 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-14-2019, 03:20 PM
  2. Replies: 7
    Last Post: 12-11-2018, 09:44 AM
  3. [SOLVED] Calculate remaining items
    By Rymar in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-07-2015, 07:18 AM
  4. [SOLVED] Vlookup with remaining items populated below
    By excelnoob927 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-31-2014, 11:07 PM
  5. [SOLVED] Need to count items in column that match multiple data items
    By bclucas55 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-27-2014, 10:03 AM
  6. Count of Items that are Greater than the Average of those Items
    By bbg22 in forum Access Tables & Databases
    Replies: 1
    Last Post: 03-19-2014, 07:07 AM
  7. Replies: 3
    Last Post: 01-21-2010, 06:58 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