+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: filtering rows

  1. #1
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    filtering rows

    I get sent a spreadsheet by my supplier every week with 1000's of products.

    i am only interested in about 50 products.

    Column A has 'reference' as a heading and below are the products numbers and in the next columns are weights and prices

    I want to be able to filter out the 'reference' numbers i am interested in, every time I get sent a new spreadsheet and put this data either somewhere on existing sheet or on a new page or even a new spreadsheet so I dont have to wade thru the huge long list.

    I have tried filtering but this would need to be set up again each time i receive a new spreadsheet.

    I think I need to make a makro but am in the dark as to how to go about this.

    Any ideas please!

    Thanks
    Last edited by peteknopp; 02-16-2010 at 12:45 PM. Reason: solved

  2. #2
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,441

    Re: filtering rows

    i am only interested in about 50 products.
    Is it always the same items?
    You might take a look at using Advanced Filter with criteria, using the option to copy the results to a new location. See this link of Advanced Filter with criteria

    The advanced filter can be easily automated with VBA. For more specific help post a sample workbook that meets the following criteria

    1. It EXACTLY duplicates the structure of your real workbook, AND
    2. It contains representative but non-sensitive dummy data, AND
    3. It manually shows the expected/desire results.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    Re: filtering rows

    Thanks Palmetto.

    Filter items in a list may do what I need, but where does it put the data?

    Attached is the type of file I use.

    From the list of reference numbers in column A i will need to select about 50 and then place the results elsewhere.

    The following week I would receive a new list and would need to again just filter out my 50 items to be displayed elsewhere.

    Thanks

    Pete
    Attached Files Attached Files

  4. #4
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,225

    Re: filtering rows

    Here's a macro that will do it. It requires you create a sheet called "MasterList" and put your list of reference numbers of importance to you in column A as a list.

    Then create a blank sheet called ExtractedList, and your raw data will go on a sheet called Data... then run this macro anytime you want a newly extracted set of data.

    Code:
    Option Explicit
    
    Sub ExtractData()
    'JBeaucaire  2/16/2010
    Dim LR As Long:     LR = Range("A" & Rows.Count).End(xlUp).Row
    Application.ScreenUpdating = False
    
    Sheets("ExtractedList").Cells.Clear
    
        With Sheets("Data")
            .Range("F1") = "Key"
            .Range("F2:F" & LR).FormulaR1C1 = "=ISNUMBER(MATCH(RC1,MasterList!C1,0))"
            .Range("F:F").AutoFilter Field:=1, Criteria1:="TRUE"
            .Range("A1:E" & LR).Copy Sheets("ExtractedList").Range("A1")
            .AutoFilterMode = False
            .Range("F:F").ClearContents
        End With
    
    Application.ScreenUpdating = True
    Sheets("ExtractedData").Activate
    Beep
    End Sub
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    Re: filtering rows

    Thanks Jbeaucaire.

    That looks spot on!
    I should have said I am a goon when it comes to Excel - I just dont use it often enough to learn it.

    Now the silly question....

    When my updated spreadsheet is emailed to me, how do I apply the macro to it? or do I copy the data on the updated sheet and paste it onto the example you did for me so that my same selected item are displayed on the extraction sheet?

    Thanks again for your time!

    Pete

  6. #6
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,225

    Re: filtering rows

    I would just drop the new data onto the DATA sheet in columns A:E (column F needs to remain clear for this macro). Run the macro and the ExtractedList is instantly updated for you.

    ======
    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated. It is found across from the "time" in each of our posts.)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  7. #7
    Forum Guru rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: filtering rows

    Following Palmetto's Adv. Filter I came up with this macro
    Code:
    Sub advFilter()
    
    Dim Ws As Worksheet
    Dim HeaderRng As Range, OutputRng As Range, FilterRng As Range, CriteriaRng As Range
    Dim Width As Long
    
    Set Ws = Worksheets("Sheet1")
    Set HeaderRng = Ws.Range(Range("A1"), Cells(1, Cells.Columns.Count).End(xlToLeft))
    Set FilterRng = HeaderRng.CurrentRegion
    Width = HeaderRng.Columns.Count
    Set OutputRng = HeaderRng.Offset(1, Width + 3)
    Set CriteriaRng = HeaderRng.Offset(1, Width + 1).Resize(1, 1)
    
    HeaderRng.Copy OutputRng 'Output Range the same
    HeaderRng.Resize(1, 1).Copy CriteriaRng 'Output Range the same
    Range("RefList").Copy CriteriaRng.Offset(1, 0)
    Set CriteriaRng = CriteriaRng.Resize(1 + Range("RefList").Rows.Count, 1)
        
      FilterRng.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=CriteriaRng, _
                               CopyToRange:=OutputRng, Unique:=True
    End Sub
    Your References go into Sheet2

    press Alt-F11 and run the macro

    I've tried to upload but It keeps on failing ??!!!

    Change this Range("RefList")
    into Range("Sheet2!A2:A51")
    Last edited by rwgrietveld; 02-16-2010 at 05:24 AM.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  8. #8
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    Re: filtering rows

    You have been more help than I can ever thank you for!

    I will do as instructed re Solved and feedback after my last dumb question.....

    Drop new data etc and then RUN MACRO. Does this happen automatically as I cant find a command.

    Cheers

    Pete

  9. #9
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,225

    Re: filtering rows

    Quote Originally Posted by peteknopp View Post
    Drop new data etc and then RUN MACRO. Does this happen automatically as I cant find a command.

    You should study up on the Excel basics, running a macro can be done right from the Tools > Macros menu, or by pressing Alt-F8.

    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  10. #10
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    Re: filtering rows

    Thanks also Ricardo - I shall look at your option if it uploads but dont want to distract myself from JBeaucaires answer which is working for me!!! As mentioned before - I'm easily confused in Excel!

  11. #11
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    Re: filtering rows

    Jbeaucaire - I am using a Mac and TOOLS - Macro is where I went but no Macros listed. Is there a name for your macro that i need to insert.

    The example you uploaded seemed to work automatically.
    Last edited by peteknopp; 02-16-2010 at 05:36 AM.

  12. #12
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    Re: filtering rows

    I have just copied and pasted an earlier data sheet onto the example you made and the Extracted list has not updated. I go tools - macro and it asks for macro name. I do alt f8 and nothing happens. Please help at my last hurdle!

    Thanks

    Pete

  13. #13
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    Re: filtering rows

    office for mac wont run vbm so maybe i am best off trying all this in windows?

  14. #14
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    Re: filtering rows

    i have tried this in windows but

    Sub ExtractData()
    'JBeaucaire 2/16/2010
    Dim LR As Long: LR = Range("A" & Rows.Count).End(xlUp).Row
    Application.ScreenUpdating = False

    Sheets("ExtractedList").Cells.Clear

    With Sheets("Data")
    .Range("F1") = "Key"
    .Range("F2:F" & LR).FormulaR1C1 = "=ISNUMBER(MATCH(RC1,MasterList!C1,0))"
    .Range("F:F").AutoFilter Field:=1, Criteria1:="TRUE"
    .Range("A1:E" & LR).Copy Sheets("ExtractedList").Range("A1")
    .AutoFilterMode = False
    .Range("F:F").ClearContents
    End With

    Application.ScreenUpdating = True
    Sheets("ExtractedData").Activate
    Beep
    End Sub


    run time error 9
    script out of range

  15. #15
    Registered User
    Join Date
    02-15-2010
    Location
    portugal
    MS-Off Ver
    Excel 2008
    Posts
    11

    Re: filtering rows

    is it because highlighted line has EXTRACTEDDATA and elsewhere it reads EXTRACTEDLIST

    I edited the macro to read extractedlist and the macro ran but with no data on the extractedlist sheet

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