Extracting Raw Data into Different Excel Sheet

shahid5788

Board Regular
Joined
May 24, 2016
Messages
91
Hi I have a huge Raw data. Can someone please assist me with some sort of formula or vba code that can extract my data into different excel sheets. I need a formula or vba code that looks into my “Project Status” column and extract all my “Active” data into one sheet. Then extract all my “#N/A” into another work sheet. And finally all my “Closed” project into another sheet. Can someone please assist me with this issue?

Thanks



Full NameEmployee #HoursProjectDept IDProject Status ID
Andrew Chen123478885149-04-1252-BT180Active149
Andrew Chen1234788810149-04-1252-BT180Active149
Andrew Chen123478885108-01-1247-BT180Active108
Andrew Chen1234788810108-01-1247-BT180Active108
Rob Graif1234787010Fin600#N/A#N/A
Rob Graif1234787010Fin600#N/A#N/A
Brian Lee9999788910149-04-1252-BT600Active149
Brian Lee999978895149-04-1252-BT600Active149
James Hawthorn730012455108-01-1247-BT600Active108
Justin Ho7454787510108-01-1247-BT380Active108
Shannon Brown730119995149-01-1250-BT440Closed149
Lee Hoang7300787451-02-1261-BT600Closed1
Belly Marton730087875817-01-BT440Active817
Belly Marton73008787101-02-1261-BT440Closed1
Belly Marton73008787151-02-1261-BT440Closed1
Belly Marton7300878710108-03-1265-BT440Active108
Adrian Peterson730045715PRJ-FY17-1-20 (834) BT600#N/A#N/A
Ryding Lee7300456710817-01-BT440Active817
Ryding Lee730045675817-01-BT440Active817
Ryding Lee7300456710817-01-BT440Active817

<tbody>
</tbody>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I recreated your workbook. I named the sheet with your data "Data". Then I created 3 sheets named "Active", "Closed", and "NA". You will need to either name your sheets that way or alter the code.

Then run the following code.


Code:
Sub CopyOver()
Application.ScreenUpdating = False
Dim wsAR()
Dim r As Range
Dim tmp As Range
Dim c As Range
Dim ws As Worksheet
Dim wTmp As Worksheet
wsAR = Array("Active", "Closed", "#N/A")
Set ws = Sheets("Data")
Set r = ws.Range("A1").CurrentRegion
For i = 0 To UBound(wsAR)
    Set wTmp = Sheets(Replace(Replace(wsAR(i), "#", ""), "/", ""))
    r.AutoFilter Field:=6, Criteria1:=wsAR(i)
    Set tmp = r.SpecialCells(xlCellTypeVisible)
    tmp.Copy
    wTmp.Range("A1").PasteSpecial xlPasteValues
    r.AutoFilter
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi

Is there way to modify this macro a little. Currently it spits out all the #N/A from the "Project Status" column. How would you modify this VBA code that it looks for all #N/A in the "Employee" column as well and puts it into the "NA" tab. See for example below. You assistance is greatly appreciated.


Full NameEmployee #HoursProjectDept IDProject StatusID
Andrew Chen123478885149-04-1252-BT180Active149
Andrew Chen1234788810149-04-1252-BT180Active149
Andrew Chen123478885108-01-1247-BT180Active108
Andrew Chen#N/A10108-01-1247-BT180Active108
Rob Graif1234787010Fin600#N/A#N/A

<tbody>
</tbody>
 
Upvote 0
I'm not sure why that is happening. On my test workbook where I pasted your data, it does move the #N/A entries to the NA tab.
 
Upvote 0
On you test workbook everything worked perfectly. I was just wondering if can add another condition in also picking up the "Employee #" column and if there is a #N/A even if the "Project Status" says "Active" that it spits that #N/A into the NA TAB that was made. Hopefully I explained that good enough.
 
Upvote 0
How about this.

Code:
Sub CopyOver()
Application.ScreenUpdating = False
Dim wsAR()
Dim r As Range
Dim tmp As Range
Dim tmp2 As Range
Dim c As Range
Dim ws As Worksheet
Dim wTmp As Worksheet
Dim s As String
wsAR = Array("Active", "Closed", "#N/A")
Set ws = Sheets("Data")
Set r = ws.Range("A1").CurrentRegion


For i = 0 To UBound(wsAR)
    Set wTmp = Sheets(Replace(Replace(wsAR(i), "#", ""), "/", ""))
    If wTmp.Name = "NA" Then
        Set r = r.Resize(r.Rows.Count, r.Columns.Count + 1)
        Set tmp2 = r.Offset(1, 7).Resize(r.Rows.Count - 1, 1)
        tmp2.FormulaR1C1 = "=OR(ISNA(RC[-6]),ISNA(RC[-2]))"
        r.AutoFilter Field:=8, Criteria1:=True
        tmp2.Clear
    Else
        r.AutoFilter Field:=6, Criteria1:=wsAR(i)
    End If
    Set tmp = r.SpecialCells(xlCellTypeVisible)
    tmp.Copy
    wTmp.Range("A1").PasteSpecial xlPasteValues
    r.AutoFilter
    wTmp.Range("A:G").Columns.AutoFit
    tmp2.Clear
Next i


Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi, I am getting an error with this code. I have same format excel sheet setup that was used for earlier vba code


"Run-time error '91':
Objective variable or With block variable not set
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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