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
<tbody>
</tbody>
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 Hamilto | 238.37 | 10 | 400 | 59000 | 2030 | 20022 | ||||||
Job 20021 - Phoenix in Hamilto | 125.11 | 10 | 400 | 59005 | 2030 | 20021 | ||||||
Job 20022 - | 209.23 | 10 | 400 | 59010 | 2030 | 20022 | ||||||
Job 20022 - Phoenix in Hamilto | 78.58 | 10 | 400 | 59025 | 2030 | 20022 | ||||||
Job 47217 - | 54.89 | 10 | 400 | 59010 | 4220 | 47217 | ||||||
Job 47217 - Training | 40.18 | 10 | 400 | 59025 | 4220 | 47217 | ||||||
10 | 400 | 59005 | 2030 | 20022 | 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