Microsoft Excel - Excel Filters Criteria & Select Visible Cell

Asked By Rajender Prasad on 05-Aug-13 08:10 PM
I have data of 100 rows, I have to filter the data based on criteria, I am filtering A,B,C coulmns, I want the value of D column after my criteria got selected.
Harry Boughen replied to Rajender Prasad on 05-Aug-13 10:04 PM
Hello Prasad,
Some example data in a worksheet with desired output would help.
Regards
Harry
Rajender Prasad replied to Harry Boughen on 06-Aug-13 04:24 AM
Input Data Something like :

A B C D E
PA S5820 001 4242
PA S5820 002 4242
PA S5921 003 4242
CA S561 001 4235
CA S1234 002 4235
CA S3634 003 4235
MT A1446 001 4564
MT F314 002 4564
MT R134 003 4564

From the Above data, I am selecting filters like in Coulmn A "MT", Column B "A1446", & Column C "003", I want the output of Column D "4564", Which is the last row from the above data. If I filter 9th row is the output. when I am using offset it is giving the value 4242 instead 4564. Please help
Harry Boughen replied to Rajender Prasad on 06-Aug-13 06:33 AM
Hello Prasad,
How are you doing the filtering?  Are you using the inbuilt filter via Data/Filter/AutoFilter or are you trying to do it some other way?
The former leaves you with one row in which ColD shows 4564.
Regards
Harry
Harry Boughen replied to Rajender Prasad on 06-Aug-13 05:09 PM
Hello again Prasad,
If you want to use a formula to extract your value, if you have your selection criteria (MT in G2 and A1446 in H2) then the following formula gives the value .

=SUMPRODUCT((A2:A10=G2)*(B2:B10=H2),D2:D10)

Regards
Harry
Rajender Prasad replied to Harry Boughen on 07-Aug-13 06:42 PM
thanku fr the reply..i would requst u to giv in vba,
Harry Boughen replied to Rajender Prasad on 08-Aug-13 03:43 AM
Hello Prasad,
With your criteria in I2 and J2, this macro will put the required value in K2.

Sub find()

Dim rngDataCol, rngCell As Range

Set rngDataCol = Sheets("Sheet1").Range(Range("A2"), Range("A2").End(xlDown))
For Each rngCell In rngDataCol
    If rngCell.Value = Range("I2").Value And rngCell.Offset(0, 1).Value = Range("J2").Value Then
      Range("K2").Value = rngCell.Offset(0, 3).Value
    End If
Next

End Sub

Regards
Harry