+ Reply to Thread
Results 1 to 7 of 7

Thread: how to copy a table of numbers to another table, but select for criteria?

  1. #1
    Registered User
    Join Date
    07-16-2011
    Location
    Boston
    MS-Off Ver
    Excel 2003
    Posts
    10

    how to copy a table of numbers to another table, but select for criteria?

    I have 2 columns of numbers to be compared by the chi squared test function in Excel. This function only works correctly if all of the numbers are > 5. So I'd like to remove any rows in which one of the numbers is < 5. Filtering doesn't do it - it removes those cells from my view, but the chi-squared function still gets them. So I think I need to somehow have it copy the numbers into another location on the sheet but omitting any rows according to my criteria. Is there any automated way to do that?

  2. #2
    Valued Forum Contributor dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    New Delhi, India
    MS-Off Ver
    Excel 1997, 2000, XP, 2003, 2007, 2010
    Posts
    2,398

    Re: how to copy a table of numbers to another table, but select for criteria?

    Hi Mlevin,

    So basically you need some automation which will remove the row containing number < 5.

    Use following code to achieve this :-

    Sub chk()
    
    Selection.CurrentRegion.Select
    Selection.Range("a1").Select
        While ActiveCell.Value <> ""
            If ActiveCell.Value < 5 Or ActiveCell.Offset(0, 1).Value < 5 Then
            Selection.EntireRow.Delete
            Else
            ActiveCell.Offset(1, 0).Select
            End If
    
        Wend
    End Sub
    Regards,
    DILIPandey


    <click on below 'star' if this helps>
    DILIPandey
    +919810929744
    dilipandey@gmail.com

  3. #3
    Registered User
    Join Date
    07-16-2011
    Location
    Boston
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: how to copy a table of numbers to another table, but select for criteria?

    sorry if this is a stupid question, but where does one enter this code and how does one activate it later?

  4. #4
    Registered User
    Join Date
    07-16-2011
    Location
    Boston
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: how to copy a table of numbers to another table, but select for criteria?

    Actually, if the best way is with custom code, maybe the solution is to make a chi-squared routine that just ignores such values automatically?

  5. #5
    Valued Forum Contributor dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    New Delhi, India
    MS-Off Ver
    Excel 1997, 2000, XP, 2003, 2007, 2010
    Posts
    2,398

    Re: how to copy a table of numbers to another table, but select for criteria?

    Hi melvin,

    From Excel sheet, press Alt + F11, Insert - Module, Paste this code in right side window.
    Now select your data and press Alt + F8 and run this code which must be showing there by the name of chk. Thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey
    +919810929744
    dilipandey@gmail.com

  6. #6
    Registered User
    Join Date
    07-16-2011
    Location
    Boston
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: how to copy a table of numbers to another table, but select for criteria?

    thanks!! that's great.

  7. #7
    Valued Forum Contributor dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    New Delhi, India
    MS-Off Ver
    Excel 1997, 2000, XP, 2003, 2007, 2010
    Posts
    2,398

    Re: how to copy a table of numbers to another table, but select for criteria?

    You are welcome...

    Cheers

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey
    +919810929744
    dilipandey@gmail.com

+ 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.2.0