Hello,
My team and I have launched some macro's to help incorporate automation to our processes. However one employee keeps getting an error at this spot in the code every single time. Me and another employee who are trying to troubleshoot have both ran the macro in this individuals workbook and neither him or I had an errors, we also have had this individual run the macro in a different workbook and he would still get the same error, any ideas why this would occur to this individual?
This is where the code errors out:
This is the entire code:
My team and I have launched some macro's to help incorporate automation to our processes. However one employee keeps getting an error at this spot in the code every single time. Me and another employee who are trying to troubleshoot have both ran the macro in this individuals workbook and neither him or I had an errors, we also have had this individual run the macro in a different workbook and he would still get the same error, any ideas why this would occur to this individual?
This is where the code errors out:
VBA Code:
ActiveCell.Formula2R1C1 = _
"=IFS([@[Transaction Type]]=""Retirement"",""Retired - No Coverage"",[@[TriMedx Coverage]]=""Missing Coverage"",""All Parts & Labor"",[@[TriMedx Coverage]]<>""Missing Coverage"",[@[TriMedx Coverage]])"
This is the entire code:
VBA Code:
Sub CSFormat()
'
' CSFormat Macro
'
'Speeds up macro'
Application.ScreenUpdating = False
'Select the correct worksheet and table then remove filters'
Worksheets(15).Activate
Set ListObject = Worksheets(15).ListObjects(1)
ListObject.AutoFilter.ShowAllData
'Adjust column widths'
Columns("E:E").ColumnWidth = 79
Columns("F:F").ColumnWidth = 36.82
Columns("G:G").EntireColumn.AutoFit
Columns("H:H").EntireColumn.AutoFit
Columns("I:I").ColumnWidth = 58.27
Columns("J:J").ColumnWidth = 60.36
Columns("K:K").ColumnWidth = 107.91
'Sort for Q Serial, Transaction Code, Absolute Value, Description'
ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Clear
ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(15).ListObjects(1).Name & "[QuarterSerial]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(15).ListObjects(1).Name & "[Transaction Code]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(15).ListObjects(1).Name & "[Absolute Value]"), SortOn:=xlSortOnValues, Order:= _
xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(15).ListObjects(1).Name & "[Description]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(15).ListObjects(1).Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Create a column to use the IF function, creating TMX Coverage to be Retired no coverage and All Parts for Missing then delete the unused column'
Columns("L:L").Select
Selection.Insert Shift:=xlToRight
Range(Worksheets(15).ListObjects(1).Name & "[[#Headers],[Column1]]").Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "TriMedx Coverage2"
ActiveCell.Offset(1, 0).Range(Worksheets(15).ListObjects(1).Name & "[[#Headers],[EquipmentID]]"). _
Select
ActiveCell.Formula2R1C1 = _
"=IFS([@[Transaction Type]]=""Retirement"",""Retired - No Coverage"",[@[TriMedx Coverage]]=""Missing Coverage"",""All Parts & Labor"",[@[TriMedx Coverage]]<>""Missing Coverage"",[@[TriMedx Coverage]])"
Range("L2").Select
Selection.AutoFill Destination:=Range(Worksheets(15).ListObjects(1).Name & "[TriMedx Coverage2]")
Range(Worksheets(15).ListObjects(1).Name & "[TriMedx Coverage2]").Select
Selection.Copy
Range("M2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("L:L").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
'Hide Columns Retired Date, CEID, Proration Date, and Serial'
Range("Q:Q,P:P").Select
Range(Worksheets(15).ListObjects(1).Name & "[[#Headers],[Retired Date]]").Activate
Range("Q:Q,P:P,H:H,G:G").Select
Range(Worksheets(15).ListObjects(1).Name & "[[#Headers],[CEID]]").Activate
Selection.EntireColumn.Hidden = True
'Filter and remove all 0 or empty cells from TMX Coverage by filtering the Equipment ID to blanks, then deleting TMX Coverage Values'
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=1, _
Criteria1:="="
Range("L2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("L2").Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=1
'Adjust Column Width'
Columns("L:L").ColumnWidth = 40
'Select the correct worksheet and table then remove filters'
Worksheets(16).Activate
Set ListObject = Worksheets(16).ListObjects(1)
ListObject.AutoFilter.ShowAllData
'Adjust column widths'
Columns("E:E").ColumnWidth = 79
Columns("F:F").ColumnWidth = 36.82
Columns("G:G").EntireColumn.AutoFit
Columns("H:H").EntireColumn.AutoFit
Columns("I:I").ColumnWidth = 58.27
Columns("J:J").ColumnWidth = 60.36
Columns("K:K").ColumnWidth = 107.91
'Sort for Q Serial, Transaction Code, Absolute Value, Description'
ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Clear
ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(16).ListObjects(1).Name & "[QuarterSerial]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(16).ListObjects(1).Name & "[Transaction Code]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(16).ListObjects(1).Name & "[Absolute Value]"), SortOn:=xlSortOnValues, Order:= _
xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(16).ListObjects(1).Name & "[Description]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(16).ListObjects(1).Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Create a column to use the IF function, creating TMX Coverage to be Retired no coverage and All Parts for Missing then delete the unused column'
Columns("L:L").Select
Selection.Insert Shift:=xlToRight
Range(Worksheets(16).ListObjects(1).Name & "[[#Headers],[Column1]]").Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "TriMedx Coverage2"
ActiveCell.Offset(1, 0).Range(Worksheets(16).ListObjects(1).Name & "[[#Headers],[EquipmentID]]"). _
Select
ActiveCell.Formula2R1C1 = _
"=IFS([@[Transaction Type]]=""Retirement"",""Retired - No Coverage"",[@[TriMedx Coverage]]=""Missing Coverage"",""All Parts & Labor"",[@[TriMedx Coverage]]<>""Missing Coverage"",[@[TriMedx Coverage]])"
Range("L2").Select
Selection.AutoFill Destination:=Range(Worksheets(16).ListObjects(1).Name & "[TriMedx Coverage2]")
Range(Worksheets(16).ListObjects(1).Name & "[TriMedx Coverage2]").Select
Selection.Copy
Range("M2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("L:L").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
'Hide Columns Retired Date, CEID, Proration Date, and Serial'
Range("Q:Q,P:P").Select
Range(Worksheets(16).ListObjects(1).Name & "[[#Headers],[Retired Date]]").Activate
Range("Q:Q,P:P,H:H,G:G").Select
Range(Worksheets(16).ListObjects(1).Name & "[[#Headers],[CEID]]").Activate
Selection.EntireColumn.Hidden = True
'Filter and remove all 0 or empty cells from TMX Coverage by filtering the Equipment ID to blanks, then deleting TMX Coverage Values'
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=1, _
Criteria1:="="
Range("L2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("L2").Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=1
'Adjust Column Width'
Columns("L:L").ColumnWidth = 40
'Select the correct worksheet and table then remove filters'
Worksheets(17).Activate
Set ListObject = Worksheets(17).ListObjects(1)
ListObject.AutoFilter.ShowAllData
'Adjust column widths'
Columns("E:E").ColumnWidth = 79
Columns("F:F").ColumnWidth = 40
Columns("G:G").EntireColumn.AutoFit
Columns("H:H").EntireColumn.AutoFit
Columns("I:I").ColumnWidth = 58.27
Columns("J:J").ColumnWidth = 60.36
Columns("K:K").ColumnWidth = 107.91
'Sort for Q Serial, Transaction Code, Absolute Value, Description'
ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Clear
ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(17).ListObjects(1).Name & "[QuarterSerial]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(17).ListObjects(1).Name & "[Transaction Code]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(17).ListObjects(1).Name & "[Absolute Value]"), SortOn:=xlSortOnValues, Order:= _
xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(17).ListObjects(1).Name & "[Description]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(17).ListObjects(1).Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Create a column to use the IF function, creating TMX Coverage to be Retired no coverage and All Parts for Missing then delete the unused column'
Columns("L:L").Select
Selection.Insert Shift:=xlToRight
Range(Worksheets(17).ListObjects(1).Name & "[[#Headers],[Column1]]").Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "TriMedx Coverage2"
ActiveCell.Offset(1, 0).Range(Worksheets(17).ListObjects(1).Name & "[[#Headers],[EquipmentID]]"). _
Select
ActiveCell.Formula2R1C1 = _
"=IFS([@[Transaction Type]]=""Retirement"",""Retired - No Coverage"",[@[TriMedx Coverage]]=""Missing Coverage"",""All Parts & Labor"",[@[TriMedx Coverage]]<>""Missing Coverage"",[@[TriMedx Coverage]])"
Range("L2").Select
Selection.AutoFill Destination:=Range(Worksheets(17).ListObjects(1).Name & "[TriMedx Coverage2]")
Range(Worksheets(17).ListObjects(1).Name & "[TriMedx Coverage2]").Select
Selection.Copy
Range("M2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("L:L").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
'Hide Columns Retired Date, CEID, Proration Date, and Serial'
Range("Q:Q,P:P").Select
Range(Worksheets(17).ListObjects(1).Name & "[[#Headers],[Retired Date]]").Activate
Range("Q:Q,P:P,H:H,G:G").Select
Range(Worksheets(17).ListObjects(1).Name & "[[#Headers],[CEID]]").Activate
Selection.EntireColumn.Hidden = True
'Filter and remove all 0 or empty cells from TMX Coverage by filtering the Equipment ID to blanks, then deleting TMX Coverage Values'
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=1, _
Criteria1:="="
Range("L2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("L2").Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
ActiveSheet.ListObjects(1).Range.AutoFilter Field:=1
'Adjust Column Width'
Columns("L:L").ColumnWidth = 40
'Remove code that speeds up macro'
Application.ScreenUpdating = True
End Sub