I am very new to VBA and though below works, I bet it can be written more concisely. Thank you so much!
VBA Code:
Sub trial_v2()
Dim Sales_Rep As Integer
Dim IMR As Integer
Dim DOWN_PAYMENT As Integer
Dim Tax_Adj As Integer
Dim Material As Integer
Dim Service_Item As Integer
Dim Last_Row As Long
Dim i As Long
Application.ScreenUpdating = False
With Sheets("Sheet1")
Last_Row = Range("a" & Rows.Count).End(xlUp).Row
Sales_Rep = .Rows(1).Find(What:="Sales Representative Name", LookAt:=xlWhole, MatchCase:=False).Column
.Columns(Sales_Rep + 1).Insert
.Range(.Cells(2, Sales_Rep + 1), .Cells(Last_Row, Sales_Rep + 1)).Formula2R1C1 = "=VLOOKUP(RC[-1],'[Book1.xlsm]IMR Table'!C1:C2,2,FALSE)"
.Cells(1, Sales_Rep + 1).FormulaR1C1 = "IMR"
IMR = Sales_Rep + 1
.Columns(IMR).Copy
.Columns(IMR).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
.Columns(Sales_Rep).Delete
Last_Row = Range("a" & Rows.Count).End(xlUp).Row
.Cells(1, Columns.Count).End(xlToLeft).Offset(0, 3).Formula = "Down Payment?"
DOWN_PAYMENT = .Rows(1).Find(What:="Down Payment?", LookAt:=xlWhole, MatchCase:=False).Column
.Range(.Cells(2, DOWN_PAYMENT), .Cells(Last_Row, DOWN_PAYMENT)).Formula2R1C1 = _
"=or(isnumber(search(""Down Pay"",INDEX(C[" & 1 + (0 - DOWN_PAYMENT) & "]:C,row(RC),match(""Material"",(R1),0)))),isnumber(search(""Down Pay"",INDEX(C[" & 1 + (0 - DOWN_PAYMENT) & "]:C,row(RC),match(""Billing Type Description"",(R1),0)))),isnumber(search(""Down Pay"",INDEX(C[" & 1 + (0 - DOWN_PAYMENT) & "]:C,row(RC),match(""Material Description"",(R1),0)))))"
For i = Last_Row To 2 Step -1
If Cells(i, DOWN_PAYMENT).Value = True Then
Rows(i).EntireRow.Delete
End If
Next i
.Columns(DOWN_PAYMENT).Delete
Last_Row = Range("a" & Rows.Count).End(xlUp).Row
.Cells(1, Columns.Count).End(xlToLeft).Offset(0, 3).Formula = "Tax Adj?"
Tax_Adj = .Rows(1).Find(What:="Tax Adj?", LookAt:=xlWhole, MatchCase:=False).Column
.Range(.Cells(2, Tax_Adj), .Cells(Last_Row, Tax_Adj)).Formula2R1C1 = _
"=or(isnumber(search(""TAXADJ"",INDEX(C[" & 1 + (0 - Tax_Adj) & "]:C,row(RC),match(""Material"",(R1),0)))),isnumber(search(""Tax Adj"",INDEX(C[" & 1 + (0 - Tax_Adj) & "]:C,row(RC),match(""Material Description"",(R1),0)))))"
For i = Last_Row To 2 Step -1
If Cells(i, Tax_Adj).Value = True Then
Rows(i).EntireRow.Delete
End If
Next i
.Columns(Tax_Adj).Delete
Last_Row = Range("a" & Rows.Count).End(xlUp).Row
.Cells(1, Columns.Count).End(xlToLeft).Offset(0, 3).Formula = "Service Item?"
Service_Item = .Rows(1).Find(What:="Service Item?", LookAt:=xlWhole, MatchCase:=False).Column
Material = .Rows(1).Find(What:="Material", LookAt:=xlWhole, MatchCase:=False).Column
.Range(.Cells(2, Service_Item), .Cells(Last_Row, Service_Item)).Formula2R1C1 = _
"=ISNUMBER(MATCH(RC[" & (Material - Service_Item) & "],'[Book1.xlsm]IMR Table'!C9,0))"
For i = Last_Row To 2 Step -1
If Cells(i, Service_Item).Value = True Then
Rows(i).EntireRow.Delete
End If
Next i
.Columns(Service_Item).Delete
Last_Row = Range("a" & Rows.Count).End(xlUp).Row
.Cells(1, Columns.Count).End(xlToLeft).Offset(0, 3).Formula = "Blank Project ID?"
Blank_Project_ID = .Rows(1).Find(What:="Blank Project ID?", LookAt:=xlWhole, MatchCase:=False).Column
Project_ID = .Rows(1).Find(What:="Project ID", LookAt:=xlWhole, MatchCase:=False).Column
.Range(.Cells(2, Blank_Project_ID), .Cells(Last_Row, Blank_Project_ID)).Formula2R1C1 = _
"=AND(VALUE(RC1)>0,LEN(RC[" & (Project_ID - Blank_Project_ID) & "])<2)"
Application.ScreenUpdating = True
End With
Cells(1, 1).Select
End Sub