Macro to remove repeat values from side by side cells and copy to new book

leebird1

New Member
Joined
Sep 29, 2016
Messages
15
Hello,

I have a macro code that takes the information from a csv file, ignore the following strings "*22000*", "*22005*", "*22025*", "60-*", "*20000*"
and populates the remaining accounts from columns V and W onto the "New Requests" sheet in the macro book. On the csv file there may be several rows with identical values in columns V and W
The macro does not list all the repeated V+W columns but only lists them once.

For some reason in the attachment - (10-400-59005-2030 20022) was not listed on the "New requests" sheet. I suspect it's because there are several "20022" values in column V and not picking all the values up from column W. Not sure what is wrong with the code?
Any help is appreciated. Thank you

Job 20022 - Phoenix in Hamilto238.371040059000203020022
Job 20021 - Phoenix in Hamilto125.111040059005203020021
Job 20022 -209.231040059010203020022
Job 20022 - Phoenix in Hamilto78.581040059025203020022
Job 47217 -54.891040059010422047217
Job 47217 - Training40.181040059025422047217
1040059005203020022 this did not populate on this sheet when the macro was run
this is from row 15 on the csv file



<tbody>
</tbody>
Code:
Sub concurerrorsextract()


Dim a, rng As Range
    Dim mRng As Range
    Dim vRng As Range


   Application.ScreenUpdating = False
    
    a = Array("*22000*", "*22005*", "*22025*", "60-*", "*20000*")
    Rows(1).Insert: [v1].Value = "zzz"
    With [a2].CurrentRegion
        With .Offset(, .Columns.Count + 2).Cells(1)
            .Value = "zzz"
            .Offset(1).Resize(UBound(a) + 1).Value = _
            Application.Transpose(a)
            Set rng = .CurrentRegion
        End With
        .AdvancedFilter 1, rng
        .Offset(1).EntireRow.Delete
        .Parent.ShowAllData: rng.Clear
    End With
    
    [M1].Value = "aaa"
    
    ActiveSheet.UsedRange.RemoveDuplicates Columns:=22, Header:=xlYes
    
   Set mRang = Range("M2:M" & Range("A" & Rows.Count).End(xlUp).Row)
   Set wRang = Range("W2:W" & Range("A" & Rows.Count).End(xlUp).Row)
   
   ActiveSheet.UsedRange.AutoFilter Field:=13, Criteria1:="="


On Error Resume Next


mRang.SpecialCells(xlCellTypeVisible).Value = "No Descripion"


ActiveSheet.UsedRange.AutoFilter


On Error Resume Next


ActiveSheet.UsedRange.AutoFilter Field:=23, Criteria1:="="


wRang.SpecialCells(xlCellTypeVisible).Value = "Delete"


ActiveSheet.AutoFilterMode = False


Rows("1:1").Delete Shift:=xlUp


Application.ScreenUpdating = True


ActiveSheet.UsedRange.Columns.AutoFit


ActiveSheet.ConcurExtractErrors.Select


Range("V1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Range("AB1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("AF5").Select
    Application.CutCopyMode = False
    Columns("AB:AB").EntireColumn.AutoFit
    Columns("AB:AB").Select
    Selection.TextToColumns Destination:=Range("AB1"), DataType:=xlFixedWidth, _
        FieldInfo:=Array(Array(0, 1), Array(2, 1), Array(3, 1), Array(6, 1), Array(7, 1), Array _
        (12, 1), Array(13, 1)), TrailingMinusNumbers:=True
    Range("AC:AC,AE:AE,AG:AG").Select
    Range("AG1").Activate
    Selection.Delete Shift:=xlToLeft
    Range("AF1").Select
    ActiveWindow.SmallScroll Down:=-9
    Range("W1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Range("AF1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Selection.Replace What:="Delete", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Columns("AB:AF").Select
    Columns("AB:AF").EntireColumn.AutoFit
    Range("AB1:AF1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("New Requests").Select
    Range("G2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    Range("G29").Select
    Sheets("Concur Extract Errors").Select
    ActiveWindow.SmallScroll Down:=-6
    Application.CutCopyMode = False
    ActiveWindow.SmallScroll Down:=-15
    Range("M1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("New Requests").Select
    Range("E2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("F6").Select
    Columns("E:E").EntireColumn.AutoFit
    Sheets("Concur Extract Errors").Select
    Application.CutCopyMode = False
    ActiveWindow.SmallScroll Down:=-9
    Range("O1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("New Requests").Select
    Range("F2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("H7").Select
    Application.CutCopyMode = False
    Range("A2").Select
    ActiveCell.FormulaR1C1 = ""
    Range("D2").Select
    ActiveCell.FormulaR1C1 = "Concur - Employee Expense"
    Range("D2").Select
    Selection.AutoFill Destination:=Range("D2:D52")
    Range("D2:D52").Select
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "Xiao, Jane"
    Range("C2").Select
    Selection.AutoFill Destination:=Range("C2:C52")
    Range("C2:C52").Select
    Range("B2").Select
    ActiveCell.FormulaR1C1 = "=TODAY()"
    Range("B2").Select
    Selection.AutoFill Destination:=Range("B2:B52")
    Range("B2:B52").Select
    Range("A2").Select
    ActiveCell.FormulaR1C1 = "=TODAY()"
    Range("A2").Select
    Selection.AutoFill Destination:=Range("A2:A52")
    Range("A2:A52").Select
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("C7").Select
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

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