Hi guys,
Not a programmer here but I have to work with some VBA script that was legacy from the previous guy.
We added a new column, column I time and date field, into the spreadsheet and I made some adjustments but I am still getting a Type Mismatch error in line 405. I think its pretty easy im just not a programmer. Can anyone help?
Sub ProcessingPOsData()
Dim Connection As ADODB.Connection
Dim rs As New ADODB.Recordset
Set Connection = New ADODB.Connection
Connection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\" & ThisWorkbook.Name & ";Extended Properties=""Excel 12.0 Macro;HDR=YES;"""
'2A through 2C
Sheets("AP Working").Select
ActiveCell.SpecialCells(xlLastCell).Select
LastRow = getlastrow("AP Working", "A")
Rows(LastRow - 1 & ":" & LastRow).Select
Selection.Delete Shift:=xlUp
Rows("1:3").Select
Selection.Delete Shift:=xlUp
'2D - 2E
Cells.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
'2F
' Cells.Select
' ActiveWorkbook.Worksheets("AP Working").Sort.SortFields.Clear
' ActiveWorkbook.Worksheets("AP Working").Sort.SortFields.Add2 Key:=Range("D2" & getlastrow("AP Working", "A") _
' ), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
' With ActiveWorkbook.Worksheets("AP Working").Sort
' .SetRange Range("A1:AC" & getlastrow("AP Working", "A"))
' .Header = xlYes
' .MatchCase = False
' .Orientation = xlTopToBottom
' .SortMethod = xlPinYin
' .Apply
' End With
'
Cells.Select
If ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllData
If ActiveSheet.FilterMode = False Then Selection.AutoFilter
Range("C7").Select
ActiveWorkbook.Worksheets("AP Working").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("AP Working").AutoFilter.Sort.SortFields.Add Key:= _
Range("C:C"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("AP Working").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
' Query = "select * from [AP Working$] order by [Vendor Name] asc"
' rs.Open Query, Connection
' Sheets("AP Working").Range("A2").CopyFromRecordset rs
' rs.Close
'2G through 2K
Cells.Select
Selection.ClearFormats
Rows("1:1").Select
Selection.Font.Bold = True
Selection.Font.Underline = xlUnderlineStyleSingle
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "PO# and Line #"
Range("A2").Select
ActiveCell.Formula = "=CONCATENATE(B2, "" - Line "",F2)"
Range("A3").Select
'2L through 2O
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A" & getlastrow("AP Working", "B"))
Range("A2:A" & getlastrow("AP Working", "A")).Select
Columns("A:A").Select
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Columns("B:H").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.FormatConditions.Delete
Range("B1").Select
ActiveCell.FormulaR1C1 = "Status Keyword"
Range("C1").Select
ActiveCell.FormulaR1C1 = "AP Notes"
Range("D1").Select
ActiveCell.FormulaR1C1 = "AP Contact"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Order Quantity not Accepted"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Received not Accepted"
Range("G1").Select
ActiveCell.FormulaR1C1 = "Accepted not Vouchered"
Range("H1").Select
ActiveCell.FormulaR1C1 = "Line Value Remaining"
Range("H2").Select
'2P through 2R
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("S:T").Select
Columns("S:T").EntireColumn.AutoFit
Selection.ColumnWidth = 32.71
Range("U:U,Y:Y,AA:AA,AC:AC,AE:AE").Select
Range("AE1").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 15847394
.TintAndShade = 0
'.Patte
End With
'2S
Range("V:V,W:W,X:X,Z:Z,AB:AB,AD:AD").Select
Range("AD1").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Selection.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
'2T through 2V
Range("E2").Select
Application.CutCopyMode = False
ActiveCell.Formula = "=U2-AA2"
Range("F2").Select
Application.CutCopyMode = False
ActiveCell.Formula = "=Y2-AA2-AE2"
Range("G2").Select
Application.CutCopyMode = False
ActiveCell.Formula = "=AA2-AC2"
Range("H2").Select
Application.CutCopyMode = False
ActiveCell.Formula = "=X2-AD2"
Range("H3").Select
Range("E2:H2").Select
Selection.AutoFill Destination:=Range("E2:H" & getlastrow("AP Working", "A"))
Range("E2:H" & getlastrow("AP Working", "A")).Select
For Each cell In Range("A2:A" & getlastrow("AP Working", "A"))
VendorID = Range("K" & cell.Row).Value
'Debug.Print (VendorID)
If IsError(Application.Match(Left(VendorID, 3) & "*", ThisWorkbook.Sheets("Setup").Range("A:A"), 0)) Then
'Debug.Print (Left(VendorID, 3))
'If Left(VendorID, 3) <> "190" And Left(VendorID, 3) <> "142" And Left(VendorID, 3) <> "126" And Left(VendorID, 3) <> "148" Then
Range("B" & cell.Row).Value = "NOT HUNTSVILLE"
Range("C" & cell.Row).Value = "NOT HUNTSVILLE"
End If
Next cell
'3D - 3F
For Each cell In Range("A2:A" & getlastrow("AP Working", "A"))
OrderQuantityNotAccepted = Range("E" & cell.Row).Value
ReceivedNotAccepted = Range("F" & cell.Row).Value
AcceptedNotVouchered = Range("G" & cell.Row).Value
LineValueRemaining = Range("H" & cell.Row).Value
StatusKeyword = Range("B" & cell.Row).Value
LineStatusType = Range("N" & cell.Row).Value
[highlight #FCE94F] If OrderQuantityNotAccepted = 0 And ReceivedNotAccepted = 0 And AcceptedNotVouchered = 0 And LineValueRemaining = 0 And Len(StatusKeyword) = 0 And LineStatusType = "C" Then[/highlight]
Range("B" & cell.Row).Value = "CLOSED"
Range("C" & cell.Row).Value = "CLOSED: If there was a Quantity, all have been R/A, all has been vouchered and pd and $0 line value remaining"
End If
If OrderQuantityNotAccepted = 0 And ReceivedNotAccepted = 0 And AcceptedNotVouchered = 0 And LineValueRemaining = 0 And Len(StatusKeyword) = 0 And LineStatusType = "V" Then
Range("B" & cell.Row).Value = "VOIDED"
Range("C" & cell.Row).Value = "PO Line Status is ""V"" no further action required"
End If
If OrderQuantityNotAccepted = 0 And ReceivedNotAccepted = 0 And AcceptedNotVouchered = 0 And LineValueRemaining = 0 And Len(StatusKeyword) = 0 And LineStatusType = "S" Then
Range("B" & cell.Row).Value = "EXCLUDE"
Range("C" & cell.Row).Value = "Exclude PO Line: Processed"
End If
Next cell
'3G - 3G3
For Each cell In Range("A2:A" & getlastrow("AP Working", "A"))
OrderQuantity = Range("U" & cell.Row).Value
OrderQuantityNotAccepted = Range("E" & cell.Row).Value
ReceivedNotAccepted = Range("F" & cell.Row).Value
AcceptedNotVouchered = Range("G" & cell.Row).Value
LineValueRemaining = Range("H" & cell.Row).Value
StatusKeyword = Range("B" & cell.Row).Value
LineStatusType = Range("N" & cell.Row).Value
If OrderQuantity <> 0 And OrderQuantityNotAccepted = 0 And ReceivedNotAccepted = 0 And AcceptedNotVouchered = 0 And Abs(LineValueRemaining) <= 100 And Len(StatusKeyword) = 0 Then
If LineStatusType = "S" Or LineStatusType = "O" Then
Range("B" & cell.Row).Value = "EXCLUDE"
Range("C" & cell.Row).Value = "Exclude PO Line: Processed)"
End If
If LineStatusType = "C" Then
Range("B" & cell.Row).Value = "CLOSED"
Range("C" & cell.Row).Value = "CLOSED: All quantities have been received, accepted and vouchered, line value remaining is within the $100/line threshold (this discrepancy would be due to such charges as tax, shipping and rounding issues)"
End If
End If
Next cell
'3H - 3J
For Each cell In Range("A2:A" & getlastrow("AP Working", "A"))
OrderQuantity = Range("U" & cell.Row).Value
LineValueRemaining = Range("H" & cell.Row).Value
LineStatusType = Range("N" & cell.Row).Value
If OrderQuantity = 0 And LineValueRemaining <= 0 And LineValueRemaining > -101 Then
If LineStatusType = "O" Or LineStatusType = "S" Then
Range("B" & cell.Row).Value = "EXCLUDE"
Range("C" & cell.Row).Value = "Exclude PO Line: Processed"
End If
If LineStatusType = "C" Then
Range("B" & cell.Row).Value = "CLOSED"
Range("C" & cell.Row).Value = "CLOSED: PO line has been vouchered, line value remaining is within the $100/line threshold (this discrepancy would be due to such charges such as tax, shipping and rounding issues)"
End If
End If
Next cell
End Sub
Sub UpdateVendorContactList()
Set Macrowb = Application.ActiveWorkbook
Set APVendorContactListWB = Application.Workbooks.Open(Sheet1.TextBoxAPVendorContactList)
flag = 0
For Each ws In APVendorContactListWB.Worksheets
If ws.Name = "AP Vendor and Contact" Then flag = 1
Next ws
If flag = 0 Then
MsgBox "Script did not find a tab named 'AP Vendor and Contact' in the Vendor Contact List workbook." & vbNewLine & "Please make sure such tab exists in the Workbook you selected and re-run step 1.", vbCritical
End
End If
If flag = 1 Then
Macrowb.Activate
Macrowb.Sheets("AP Working").Range("D2").Formula = "=VLOOKUP(K2,'[" & APVendorContactListWB.Name & "]AP Vendor and Contact'!$A:$B,2,FALSE)"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2" & getlastrow("AP Working", "A"))
Range("D2" & getlastrow("AP Working", "A")).Select
APVendorContactListWB.Activate
APVendorContactLastRow = getlastrow("AP Vendor and Contact", "A")
Macrowb.Activate
Sheets("AP Working").Select
For Each cell In Range("D2" & getlastrow("AP Working", "A"))
If CStr(cell.Value) = "Error 2042" Then
MissingVendor = Range("K" & cell.Row).Value
APVendorContactListWB.Sheets("AP Vendor and Contact").Range("A" & APVendorContactLastRow + 1).Value = MissingVendor
'APVendorContactListWB.Sheets("AP Vendor and Contact").Range("A" & APVendorContactLastRow + 1).Color = 65535
APVendorContactListWB.Sheets("AP Vendor and Contact").Range("B" & APVendorContactLastRow + 1).Value = "UPDATE THIS AP CONTACT"
'APVendorContactListWB.Sheets("AP Vendor and Contact").Range("B" & APVendorContactLastRow + 1).Color = 65535
APVendorContactLastRow = APVendorContactLastRow + 1
End If
Next cell
Sheets("Setup").Select
Application.ScreenUpdating = True
APVendorContactListWB.Activate
Sheets("AP Vendor and Contact").Select
Range("A" & getlastrow("AP Vendor and Contact", "A")).Select
'MsgBox getlastrow("AP Vendor and Contact", "A")
MsgBox "Step 1 complete." & vbNewLine & vbNewLine & "Now please update contacts for the new Vendor IDs added at the end of list on 'AP Vendor and Contact' tab in Vendor Contacts workbook." & vbNewLine & _
"Save changes, close Vendor Contacts workbook, and run Step 2.", vbInformation
End If
End Sub
Not a programmer here but I have to work with some VBA script that was legacy from the previous guy.
We added a new column, column I time and date field, into the spreadsheet and I made some adjustments but I am still getting a Type Mismatch error in line 405. I think its pretty easy im just not a programmer. Can anyone help?
Sub ProcessingPOsData()
Dim Connection As ADODB.Connection
Dim rs As New ADODB.Recordset
Set Connection = New ADODB.Connection
Connection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\" & ThisWorkbook.Name & ";Extended Properties=""Excel 12.0 Macro;HDR=YES;"""
'2A through 2C
Sheets("AP Working").Select
ActiveCell.SpecialCells(xlLastCell).Select
LastRow = getlastrow("AP Working", "A")
Rows(LastRow - 1 & ":" & LastRow).Select
Selection.Delete Shift:=xlUp
Rows("1:3").Select
Selection.Delete Shift:=xlUp
'2D - 2E
Cells.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
'2F
' Cells.Select
' ActiveWorkbook.Worksheets("AP Working").Sort.SortFields.Clear
' ActiveWorkbook.Worksheets("AP Working").Sort.SortFields.Add2 Key:=Range("D2" & getlastrow("AP Working", "A") _
' ), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
' With ActiveWorkbook.Worksheets("AP Working").Sort
' .SetRange Range("A1:AC" & getlastrow("AP Working", "A"))
' .Header = xlYes
' .MatchCase = False
' .Orientation = xlTopToBottom
' .SortMethod = xlPinYin
' .Apply
' End With
'
Cells.Select
If ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllData
If ActiveSheet.FilterMode = False Then Selection.AutoFilter
Range("C7").Select
ActiveWorkbook.Worksheets("AP Working").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("AP Working").AutoFilter.Sort.SortFields.Add Key:= _
Range("C:C"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("AP Working").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
' Query = "select * from [AP Working$] order by [Vendor Name] asc"
' rs.Open Query, Connection
' Sheets("AP Working").Range("A2").CopyFromRecordset rs
' rs.Close
'2G through 2K
Cells.Select
Selection.ClearFormats
Rows("1:1").Select
Selection.Font.Bold = True
Selection.Font.Underline = xlUnderlineStyleSingle
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "PO# and Line #"
Range("A2").Select
ActiveCell.Formula = "=CONCATENATE(B2, "" - Line "",F2)"
Range("A3").Select
'2L through 2O
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A" & getlastrow("AP Working", "B"))
Range("A2:A" & getlastrow("AP Working", "A")).Select
Columns("A:A").Select
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Columns("B:H").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.FormatConditions.Delete
Range("B1").Select
ActiveCell.FormulaR1C1 = "Status Keyword"
Range("C1").Select
ActiveCell.FormulaR1C1 = "AP Notes"
Range("D1").Select
ActiveCell.FormulaR1C1 = "AP Contact"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Order Quantity not Accepted"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Received not Accepted"
Range("G1").Select
ActiveCell.FormulaR1C1 = "Accepted not Vouchered"
Range("H1").Select
ActiveCell.FormulaR1C1 = "Line Value Remaining"
Range("H2").Select
'2P through 2R
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("S:T").Select
Columns("S:T").EntireColumn.AutoFit
Selection.ColumnWidth = 32.71
Range("U:U,Y:Y,AA:AA,AC:AC,AE:AE").Select
Range("AE1").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 15847394
.TintAndShade = 0
'.Patte
End With
'2S
Range("V:V,W:W,X:X,Z:Z,AB:AB,AD:AD").Select
Range("AD1").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Selection.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
'2T through 2V
Range("E2").Select
Application.CutCopyMode = False
ActiveCell.Formula = "=U2-AA2"
Range("F2").Select
Application.CutCopyMode = False
ActiveCell.Formula = "=Y2-AA2-AE2"
Range("G2").Select
Application.CutCopyMode = False
ActiveCell.Formula = "=AA2-AC2"
Range("H2").Select
Application.CutCopyMode = False
ActiveCell.Formula = "=X2-AD2"
Range("H3").Select
Range("E2:H2").Select
Selection.AutoFill Destination:=Range("E2:H" & getlastrow("AP Working", "A"))
Range("E2:H" & getlastrow("AP Working", "A")).Select
For Each cell In Range("A2:A" & getlastrow("AP Working", "A"))
VendorID = Range("K" & cell.Row).Value
'Debug.Print (VendorID)
If IsError(Application.Match(Left(VendorID, 3) & "*", ThisWorkbook.Sheets("Setup").Range("A:A"), 0)) Then
'Debug.Print (Left(VendorID, 3))
'If Left(VendorID, 3) <> "190" And Left(VendorID, 3) <> "142" And Left(VendorID, 3) <> "126" And Left(VendorID, 3) <> "148" Then
Range("B" & cell.Row).Value = "NOT HUNTSVILLE"
Range("C" & cell.Row).Value = "NOT HUNTSVILLE"
End If
Next cell
'3D - 3F
For Each cell In Range("A2:A" & getlastrow("AP Working", "A"))
OrderQuantityNotAccepted = Range("E" & cell.Row).Value
ReceivedNotAccepted = Range("F" & cell.Row).Value
AcceptedNotVouchered = Range("G" & cell.Row).Value
LineValueRemaining = Range("H" & cell.Row).Value
StatusKeyword = Range("B" & cell.Row).Value
LineStatusType = Range("N" & cell.Row).Value
[highlight #FCE94F] If OrderQuantityNotAccepted = 0 And ReceivedNotAccepted = 0 And AcceptedNotVouchered = 0 And LineValueRemaining = 0 And Len(StatusKeyword) = 0 And LineStatusType = "C" Then[/highlight]
Range("B" & cell.Row).Value = "CLOSED"
Range("C" & cell.Row).Value = "CLOSED: If there was a Quantity, all have been R/A, all has been vouchered and pd and $0 line value remaining"
End If
If OrderQuantityNotAccepted = 0 And ReceivedNotAccepted = 0 And AcceptedNotVouchered = 0 And LineValueRemaining = 0 And Len(StatusKeyword) = 0 And LineStatusType = "V" Then
Range("B" & cell.Row).Value = "VOIDED"
Range("C" & cell.Row).Value = "PO Line Status is ""V"" no further action required"
End If
If OrderQuantityNotAccepted = 0 And ReceivedNotAccepted = 0 And AcceptedNotVouchered = 0 And LineValueRemaining = 0 And Len(StatusKeyword) = 0 And LineStatusType = "S" Then
Range("B" & cell.Row).Value = "EXCLUDE"
Range("C" & cell.Row).Value = "Exclude PO Line: Processed"
End If
Next cell
'3G - 3G3
For Each cell In Range("A2:A" & getlastrow("AP Working", "A"))
OrderQuantity = Range("U" & cell.Row).Value
OrderQuantityNotAccepted = Range("E" & cell.Row).Value
ReceivedNotAccepted = Range("F" & cell.Row).Value
AcceptedNotVouchered = Range("G" & cell.Row).Value
LineValueRemaining = Range("H" & cell.Row).Value
StatusKeyword = Range("B" & cell.Row).Value
LineStatusType = Range("N" & cell.Row).Value
If OrderQuantity <> 0 And OrderQuantityNotAccepted = 0 And ReceivedNotAccepted = 0 And AcceptedNotVouchered = 0 And Abs(LineValueRemaining) <= 100 And Len(StatusKeyword) = 0 Then
If LineStatusType = "S" Or LineStatusType = "O" Then
Range("B" & cell.Row).Value = "EXCLUDE"
Range("C" & cell.Row).Value = "Exclude PO Line: Processed)"
End If
If LineStatusType = "C" Then
Range("B" & cell.Row).Value = "CLOSED"
Range("C" & cell.Row).Value = "CLOSED: All quantities have been received, accepted and vouchered, line value remaining is within the $100/line threshold (this discrepancy would be due to such charges as tax, shipping and rounding issues)"
End If
End If
Next cell
'3H - 3J
For Each cell In Range("A2:A" & getlastrow("AP Working", "A"))
OrderQuantity = Range("U" & cell.Row).Value
LineValueRemaining = Range("H" & cell.Row).Value
LineStatusType = Range("N" & cell.Row).Value
If OrderQuantity = 0 And LineValueRemaining <= 0 And LineValueRemaining > -101 Then
If LineStatusType = "O" Or LineStatusType = "S" Then
Range("B" & cell.Row).Value = "EXCLUDE"
Range("C" & cell.Row).Value = "Exclude PO Line: Processed"
End If
If LineStatusType = "C" Then
Range("B" & cell.Row).Value = "CLOSED"
Range("C" & cell.Row).Value = "CLOSED: PO line has been vouchered, line value remaining is within the $100/line threshold (this discrepancy would be due to such charges such as tax, shipping and rounding issues)"
End If
End If
Next cell
End Sub
Sub UpdateVendorContactList()
Set Macrowb = Application.ActiveWorkbook
Set APVendorContactListWB = Application.Workbooks.Open(Sheet1.TextBoxAPVendorContactList)
flag = 0
For Each ws In APVendorContactListWB.Worksheets
If ws.Name = "AP Vendor and Contact" Then flag = 1
Next ws
If flag = 0 Then
MsgBox "Script did not find a tab named 'AP Vendor and Contact' in the Vendor Contact List workbook." & vbNewLine & "Please make sure such tab exists in the Workbook you selected and re-run step 1.", vbCritical
End
End If
If flag = 1 Then
Macrowb.Activate
Macrowb.Sheets("AP Working").Range("D2").Formula = "=VLOOKUP(K2,'[" & APVendorContactListWB.Name & "]AP Vendor and Contact'!$A:$B,2,FALSE)"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2" & getlastrow("AP Working", "A"))
Range("D2" & getlastrow("AP Working", "A")).Select
APVendorContactListWB.Activate
APVendorContactLastRow = getlastrow("AP Vendor and Contact", "A")
Macrowb.Activate
Sheets("AP Working").Select
For Each cell In Range("D2" & getlastrow("AP Working", "A"))
If CStr(cell.Value) = "Error 2042" Then
MissingVendor = Range("K" & cell.Row).Value
APVendorContactListWB.Sheets("AP Vendor and Contact").Range("A" & APVendorContactLastRow + 1).Value = MissingVendor
'APVendorContactListWB.Sheets("AP Vendor and Contact").Range("A" & APVendorContactLastRow + 1).Color = 65535
APVendorContactListWB.Sheets("AP Vendor and Contact").Range("B" & APVendorContactLastRow + 1).Value = "UPDATE THIS AP CONTACT"
'APVendorContactListWB.Sheets("AP Vendor and Contact").Range("B" & APVendorContactLastRow + 1).Color = 65535
APVendorContactLastRow = APVendorContactLastRow + 1
End If
Next cell
Sheets("Setup").Select
Application.ScreenUpdating = True
APVendorContactListWB.Activate
Sheets("AP Vendor and Contact").Select
Range("A" & getlastrow("AP Vendor and Contact", "A")).Select
'MsgBox getlastrow("AP Vendor and Contact", "A")
MsgBox "Step 1 complete." & vbNewLine & vbNewLine & "Now please update contacts for the new Vendor IDs added at the end of list on 'AP Vendor and Contact' tab in Vendor Contacts workbook." & vbNewLine & _
"Save changes, close Vendor Contacts workbook, and run Step 2.", vbInformation
End If
End Sub