Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: Extract data with 2 criteria

  1. #1
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    13

    Extract data with 2 criteria

    Hi.
    I have a worksheet called "agenda" and another called "Result"

    I need to return the worksheet "Output" the "Clients" (which is in worksheet "agenda"), according to cell "C1" and cells "A2", "C2", "E2", "G2", "I2 "plnilha the" Result "

    I did a manual example for you, can understand.
    Attached Files Attached Files

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    marreco, try this to start for

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    
        Dim rng As Range
        If Target.Address(0, 0) = "C1" Then
            With Worksheets("AGENDA")
                For Each rng In .UsedRange.Rows(1).Find(What:=Me.Range("C1").Value, LookAt:=xlWhole).MergeArea.Cells(1).Offset(2, 2).Offset(, -2).Resize(.UsedRange.Rows.Count - 1).Cells
                    'Modification here'
                Next rng
            End With
        End If
        
    End Sub
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    13
    Hi.

    I do not know much about vba.
    I can not imagine how to continue.
    but has a detail, your code should pull the spreadsheet data "ANGENDA" to the sheet "Result"

    Thank you!!

  4. #4
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    13
    Hi.

    Any idea?

    thank you!!

  5. #5
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    13

  6. #6
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Put this code in the Result sheet module (Right click on tab Result > View code and paste)

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    
        Dim rng As Range
        Dim c   As Range, x, y
        
        If Target.Address(0, 0) = "C1" Then
            y = Range("a2:j2").Value2
            With Worksheets("AGENDA")
                Set c = .UsedRange.Rows(1).Find(What:=Me.Range("C1").Value, LookAt:=xlWhole).MergeArea.Cells(1)
                If Not c Is Nothing Then
                    For Each rng In c.MergeArea.Cells(1).Offset(2).Offset(, 2).Resize(.UsedRange.Rows.Count - 2).Cells
                        x = Application.Match(rng.Value, y, 0)
                        If Not IsError(x) Then
                            Application.EnableEvents = False
                            Me.Cells(4, x) = rng.Offset(, -2).Value
                            Application.EnableEvents = True
                        End If
                    Next rng
                End If
            End With
        End If
        
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  7. #7
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    13
    Hi.
    I do not know why but when you change the data in "C1" worksheet "Results" in nothing happens.

  8. #8
    Member Charles's Avatar
    Join Date
    Aug 2012
    Posts
    63
    Rep Power
    13
    Hi,

    I modified the code supplied by "Admin"
    In this example I used a command button to populate the data to the "Result" sheet.
    All you need to do is select the data in C1 and click Run.
    Attached Files Attached Files
    Last edited by Charles; 11-16-2012 at 04:07 AM. Reason: added information

  9. #9
    Member
    Join Date
    Aug 2012
    Posts
    72
    Rep Power
    13
    Hi.

    Yes!!, perfect!!

    Thank you!!

  10. #10
    Member Charles's Avatar
    Join Date
    Aug 2012
    Posts
    63
    Rep Power
    13
    Thanks,
    Please check the spelling in row 2 of the "Result" sheet.
    I changed it to that of the spelling in the "Activity" sheet.
    Some of the words have a "-", but the Result sheet did not.
    You need to make sur the spelling is the same in both sheets.

Similar Threads

  1. Replies: 8
    Last Post: 06-08-2013, 01:24 PM
  2. VBA Code to Extract data
    By Howardc in forum Excel Help
    Replies: 1
    Last Post: 07-24-2012, 11:37 PM
  3. Split data based on criteria
    By Mahesh.sreekakulam in forum Excel Help
    Replies: 3
    Last Post: 06-08-2012, 09:30 PM
  4. Extract multiple data matching with input
    By excel_learner in forum Excel Help
    Replies: 1
    Last Post: 02-13-2012, 06:08 PM
  5. Extract data using Advanced Filter
    By PcMax in forum Excel Help
    Replies: 4
    Last Post: 01-02-2012, 02:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •