Option Explicit
Sub PrepareSAPPayReport()
With Application
.ScreenUpdating = False
.Calculation = xlManual
End With
Dim wsRep As Worksheet, wsRAW As Worksheet, dRow As Long, lRow As Long, rwRep As Long, c As Range, cl As Range, tmpRng As Range
Set wsRep = Sheets("3) Pay Proposal Report")
Set wsRAW = Sheets("1) Download RAW Proposal")
With wsRep
dRow = .Cells(.Rows.Count, 2).End(xlUp).Row
If dRow >= 6 Then .Range("6:" & dRow).EntireRow.Delete
End With
With wsRAW
lRow = .Cells(.Rows.Count, 31).End(xlUp).Row
For Each c In .Range("C2:C" & lRow)
If Left(c.Value, 7) = "Vendor " Then c.Value = Mid(c.Value, 8, 255) Else c.Value = c.Offset(-1).Value
Next
For Each cl In .Range("AE2:AE" & lRow).SpecialCells(xlConstants)
If IsNumeric(cl.Value) Then
If tmpRng Is Nothing Then
Set tmpRng = cl
Else
Set tmpRng = Application.Union(tmpRng, cl)
End If
End If
Next
Intersect(tmpRng.EntireRow, .Range("C:C,E:E,G:G,M:N,Q:Q,V:W,Y:Y,AB:AB,AE:AE")).Copy wsRep.Range("A6")
End With
With wsRep
rwRep = .Cells(Rows.Count, 2).End(xlUp).Row - 5
.Range("E6").Resize(rwRep).TextToColumns FieldInfo:=Array(1, 4)
.Range("F6").Resize(rwRep).TextToColumns FieldInfo:=Array(1, 4)
.Range("G6").Resize(rwRep).TextToColumns FieldInfo:=Array(1, 1), DecimalSeparator:=",", ThousandsSeparator:="."
.Range("H6").Resize(rwRep).TextToColumns FieldInfo:=Array(1, 1), DecimalSeparator:=",", ThousandsSeparator:="."
.Range("I6").Resize(rwRep).TextToColumns FieldInfo:=Array(1, 1), DecimalSeparator:=",", ThousandsSeparator:="."
With .Range("L6").Resize(rwRep)
.FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],Lookups!R1C1:R100C2,2,0)&"""","""")"
.Value = .Value
End With
End With
With Application
.Calculation = xlAutomatic
.ScreenUpdating = True
End With
End Sub