+ Reply to Thread
Results 1 to 6 of 6

Multiple categories, Looping iterations and deleting rows

  1. #1
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,139

    Multiple categories, Looping iterations and deleting rows

    I have a long dataset, see example in the attached sheet.

    For each category in Column A, I want to be able to calculate a separate robust mean, which I then need to process further. There are lots of ways of doing this. I want to use the following procedure:

    For each category in Column A, calculate the mean & SD.

    If any of the original individual values is >Mean + 1.5 SD – replace the original value with the value of Mean + 1.5 SD. If any of the original individual values is less than M-1.5 SD, replace the original individual value with Mean -1.5 SD.

    Repeat the process (calculating a new Mean and SD) 25 times. By that stage, the mean is a pretty good estimate of the robust mean.

    Then calculate an Index Score for each Value in the ORIGINAL DATA SET to show how far it is from the Robust Mean using the formula (Value – Robust mean)/66.

    If the absolute value of the Index Score exceeds 3.0, delete the entire row.

    Move on to the next category, until all of the categories in Column A have been so processed.

    Stop.

    The eagle-eyed among you may recognise the general form of the data, as I’ve posted other problems related to the same dataset previously!!
    I can do most of the above in Excel outside of VBA, but it’s very clunky. A nice VBA solution would be good to have, but, sadly, I’m not even up to the standard of Chapter 1 of "VBA Programming for Dummies".

    Thanks for looking...
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    04-30-2011
    Location
    Westhoughton, England
    MS-Off Ver
    2007, 2003,2002,2000
    Posts
    3

    Re: Multiple categories, Looping iterations and deleting rows

    Hi
    Not 100% sure of your requirement so have created routine to work on copy. If interpretation is mistaken then probably enough here to reconstruct the code to correct.


    Please Login or Register  to view this content.
    Last edited by Cutter; 09-02-2012 at 08:21 AM. Reason: Added code tags

  3. #3
    Registered User
    Join Date
    04-30-2011
    Location
    Westhoughton, England
    MS-Off Ver
    2007, 2003,2002,2000
    Posts
    3

    Re: Multiple categories, Looping iterations and deleting rows

    Had to remove many comments and indents and other details in order to get the post under 10000 characters so not very pretty and vars not well named. Error checking reduced to minimum and removed in minor functions.
    Regards,
    John

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Multiple categories, Looping iterations and deleting rows

    @ jgm27

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,139

    Re: Multiple categories, Looping iterations and deleting rows

    Thanks for this!! It doesn't quite do what I want it to do. However, with a bit of luck, I'll be able to figure it out for myself. I'll give it a go!!

  6. #6
    Registered User
    Join Date
    04-30-2011
    Location
    Westhoughton, England
    MS-Off Ver
    2007, 2003,2002,2000
    Posts
    3

    Re: Multiple categories, Looping iterations and deleting rows

    I didn't think so but if you have trouble let me know where I went wrong and I'll try to help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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