Extract Data From A List

ExcelRoy

Well-known Member
Joined
Oct 2, 2006
Messages
2,540
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am looking for a formula to extract data from a list dependent on what is in columns D

ie the list on sheet 1 will be

A1 : Parts
B1 : Description
C1 : Cost
D1 : Status

On sheet 2 I need

A1 : Parts only with "Ordered","Partially Received" or "Pending" status
B1 : Description with "Ordered","Partially Received" or "Pending" status
C1 : Cost with "Ordered","Partially Received" or "Pending" status
D1 : Status with "Ordered","Partially Received" or "Pending" status

Many thanks
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub ExtractDataDependingOnValueInColumnD()
  Dim R As Long, LastRow As Long, UnusedCol As Long
  With Sheets("Sheet1")
    LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
    UnusedCol = .Cells(1, Columns.Count).End(xlToLeft).Column + 1
    Cells(1, UnusedCol).Value = "X"
    .Cells(2, UnusedCol).Resize(LastRow - 1) = Evaluate(Replace(Replace("IF((@D2:D#=""Ordered"")+(@D2:D#=""Partially Received"")+(@D2:D#=""Pending""),""X"","""")", "#", LastRow), "@", "'" & .Name & "'!"))
    Intersect(.Columns(UnusedCol).SpecialCells(xlConstants).EntireRow, Columns("A:D")).Copy Sheets("Sheet2").Range("A1")
    Columns(UnusedCol).Clear
  End With
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top