+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 15 to 24 of 24

Thread: filtering rows

  1. #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

  2. #16
    Forum Moderator romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Alibi
    MS-Off Ver
    All
    Posts
    8,262

    Re: filtering rows

    Small change to the code:
    Code:
    Sub ExtractData()
    'JBeaucaire 2/16/2010
    Dim LR As Long
    Dim wksExtract as Worksheet
    Application.ScreenUpdating = False
    
    Set wksExtract = Sheets("ExtractedList")
    wksExtract.Cells.Clear
    
    With Sheets("Data")
    LR = .Range("A" & .Rows.Count).End(xlUp).Row
    .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 wksExtract.Range("A1")
    .AutoFilterMode = False
    .Range("F:F").ClearContents
    End With
    
    Application.ScreenUpdating = True
    wksExtract.Activate
    Beep
    End Sub
    So long, and thanks for all the fish.

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

    Re: filtering rows

    all sorted.

    changed from extracteddata to extractedlist in the macro wording and my problem was i was running bootcamp with mac leopard and windows side by side.

    I then copied new data from the excel file open on the mac into the data file on win 7 and thats when data disappeared on the extracted sheet.

    I then copied the file from the mac to win 7, opened it, copied the new data, pasted into the data sheet and the macro worked fine.

    The mac really does not like vbm and my fault for copying data from an open program.

    Once again, many thanks and sorry for the rambling posts but we got there in the end!

  4. #18
    Forum Moderator romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Alibi
    MS-Off Ver
    All
    Posts
    8,262

    Re: filtering rows

    JBeaucaire's code assumes you have the data sheet active when you start. If you don't (e.g. you have the ExtractedList sheet active), it won't work properly.
    Office 2008 doesn't support VBA but prior versions do, and supposedly the next version will again, from what I hear. Your alternative in 2008 is to use Applescript.
    So long, and thanks for all the fish.

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

    Re: filtering rows

    No, that last line of code just brings up the extracted list onscreen. Sorry about the typo.

    I don't use a MAC, so I can't give you Mac specifics about macro usage. This is how I would install the macro into my workbook:

    How/Where to install the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.
    _________________
    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!)

  6. #20
    Forum Moderator romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Alibi
    MS-Off Ver
    All
    Posts
    8,262

    Re: filtering rows

    As mentioned, Office 2008 doesn't support VBA. Sad, but true.
    So long, and thanks for all the fish.

  7. #21
    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 romperstomper View Post
    JBeaucaire's code assumes you have the data sheet active when you start. If you don't (e.g. you have the ExtractedList sheet active), it won't work properly.
    Hehe, it doesn't do that. I've used a With Sheets("Data") syntax to point all the code that works on that sheet to connect to it properly. So it works regardless of the active sheet.

    The issue may be Mac-related, and I can't speak to that.
    _________________
    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!)

  8. #22
    Forum Moderator romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Alibi
    MS-Off Ver
    All
    Posts
    8,262

    Re: filtering rows

    Yes it does:
    Code:
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Your last row variable depends on the active sheet.
    So long, and thanks for all the fish.

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

    Re: filtering rows

    Duh, you're right, it does. But you guessed incorrectly at which sheet should be active...my bad for making you guess.
    Code:
    Option Explicit
    
    Sub ExtractData()
    'JBeaucaire  2/16/2010
    Dim LR As Long
    Application.ScreenUpdating = False
    
    Sheets("ExtractedList").Cells.Clear
    
        With Sheets("Data")
            LR = .Range("A" & .Rows.Count).End(xlUp).Row      'moved to here
            .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
    Last edited by JBeaucaire; 02-16-2010 at 12:52 PM. Reason: Moved LR variable into WITH
    _________________
    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. #24
    Forum Moderator romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Alibi
    MS-Off Ver
    All
    Posts
    8,262

    Re: filtering rows

    How does that differ from what I posted?
    So long, and thanks for all the fish.

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