CPR Macro
CPR Macro
Range Dim rcount As Integer Dim WS_Count As Integer Dim IntI, IntJ As Integer Dim IntK As Integer WS_Count = ActiveWorkbook.Worksheets.Count For IntI = 1 To WS_Count If ActiveWorkbook.Worksheets(IntI).Name = "T & E" Or ActiveWorkbook.Workshee ts(IntI).Name = "Professional Services" _ Or ActiveWorkbook.Worksheets(IntI).Name = "Relocation Expenses" Or Activ eWorkbook.Worksheets(IntI).Name = "Other Costs and Indirect Costs" Then ActiveWorkbook.Worksheets(IntI).Activate For Each r In ActiveSheet.UsedRange If r.MergeArea.Count > 1 Then Set myR = r.MergeArea r.UnMerge For Each r1 In myR r1.Value2 = myR.Value2 Next r1 End If Next r Set r = Nothing If ActiveSheet.UsedRange.Cells(6, 1) = "Kimberly-Clark Corporation -- [ 1201014]" Then Rows("1:7").Select Selection.Delete Shift:=xlUp End If rcount = 1 For Each r In ActiveSheet.UsedRange If Trim(Cells(rcount, 5)) = "" Then Exit For If IsNumeric(Trim(Cells(rcount, 5))) = False And Trim(Cells(rcount, 5)) <> "Project Code" Then Debug.Print Cells(rcount, 5) Cells(rcount, 5).EntireRow.Select Debug.Print Cells(rcount, 5) Selection.Delete Shift:=xlUp End If rcount = rcount + 1 Next r rcount = 1 For Each r In ActiveSheet.UsedRange If Trim(Cells(rcount, 5)) = "" Then Exit For If IsNumeric(Trim(Cells(rcount, 5))) = False And Trim(Cells(rcount, 5)) <> "Project Code" Then Debug.Print Cells(rcount, 5) Cells(rcount, 5).EntireRow.Select Debug.Print Cells(rcount, 5) Selection.Delete Shift:=xlUp End If rcount = rcount + 1 Next r rcount = 1 For Each r In ActiveSheet.UsedRange
If Trim(Cells(rcount, 5)) = "" Then Exit For If IsNumeric(Trim(Cells(rcount, 5))) = False And Trim(Cells(rcount, 5)) <> "Project Code" Then Debug.Print Cells(rcount, 5) Cells(rcount, 5).EntireRow.Select Debug.Print Cells(rcount, 5) Selection.Delete Shift:=xlUp End If rcount = rcount + 1 Next r Dim LastCol As Integer With ActiveSheet LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column If ActiveSheet.Cells(1, LastCol) <> "Owner Name" Then Range("M1").Select Selection.Copy ActiveSheet.Cells(1, LastCol + 1) = "Owner Name" ActiveSheet.Cells(1, LastCol + 1).Select Set r = Selection Range(r.Address).Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False ActiveSheet.Cells(2, LastCol + 1).Select ' ActiveCell.Formula = "=VLOOKUP(E2,Masters!$A$2:$E$64,5,FALSE)" ActiveSheet.Cells(2, LastCol + 1).Select Set r = Selection Range(r.Address).Select '' Dim lRow As Long, lCol As Integer, mRow As Long, mCol As Integer lCol = ActiveSheet.UsedRange.Columns.Count + 1 mRow = 0 For i = 1 To lCol lRow = Range(Cells(Rows.Count, i), Cells(Rows.Count, i)).End (xlUp).Row If lRow > mRow Then mRow = lRow mCol = i Else End If Next i Lastcell = Range(Cells(mRow, lCol), Cells(mRow, lCol)).Address Range(r.Address, Lastcell).Formula = "=VLOOKUP(E2,Masters!$A$2:$ E$64,5,FALSE)" Range(r.Address, Lastcell).Font.Name = "Arial" Range(r.Address, Lastcell).Font.Size = 8 Range(r.Address, Lastcell).Font.Bold = True Range(r.Address, Lastcell).Borders.LineStyle = xlContinuous Range(r.Address, Lastcell).ColumnWidth = 12 Dim NumberOfRows As Integer NumberOfRows = Range("E65536").End(xlUp).Row ' ' ' For IntK = NumberOfRows To NumberOfRows + 4 Cells(NumberOfRows + 1, 5).EntireRow.Select Selection.Delete Shift:=xlDown
'
Next IntK
For IntJ = 2 To NumberOfRows If Range("E" & IntJ).Errors.Item(xlNumberAsText).Value Then Range("E" & IntJ) = Range("E" & IntJ) * 1 End If Next IntJ End If End With End If Next IntI End Sub