I started the second part of a macro which makes some changes to a sheet and counts the number of DL vs IDL employees in the sheet. I started on the "Regulares" sheet by recording the things I need but cant figure out how to get the count from the column "MO REAL". Like basically it should tell me the total of DL and IDL employees in that column. I recorded the macro but feel its not getting all the things I need. The bad part is that I also want to do this for another 3 sheets.
1. Add filters to row 1
2. Move the CFP (column J) and Cargo (column P) to before the MO Column I
3. Convert the CPF column to number format (thats why the multiply is there)
4. Add a column after the MO Column and name it MO REAL
5. Filter MO column K and delete all the INATIVE employees (clear filters)
6. In the MO REAL column L cell L2 add the following formula (=VLOOKUP(I2,'DL List'!A2:B34,2,0))
7. Convert formulas to Values in column L
8. Filter DL in MO column K and make sure all N/A in the MO Real column L are also DL
9. Filter (G&A, MOH, IDL, Other MOH) in the MO column K and change the N/A in the MO REAL column L to IDL
10. In the Resultados sheet Put the total count of DL employees in cell B17 and IDL in cell C17
Here is what the recorded macro code showed:
Sub DefineDL_IDL()
Dim wbTHMacro As Workbook, wsRegulares As Worksheet, wsRegularesDemitidos As Worksheet, wsTempActivos As Worksheet, _
wsTempJA As Worksheet, wsTempFit As Worksheet, wsTempDemitidos As Worksheet, wsPS As Worksheet, wsResultados As Worksheet, _
wsDLList As Worksheet, wssheet As Worksheet
Sheets("Regulares").Select
Columns("J:J").Select
Selection.Insert Shift:=xlToRight
Range("J1").Select
ActiveCell.FormulaR1C1 = "MO REAL"
Range("J2").Select
Columns("J:K").EntireColumn.AutoFit
Columns("K:K").Select
Selection.Cut
Columns("I:I").Select
Selection.Insert Shift:=xlToRight
Columns("Q:Q").Select
Selection.Cut
Columns("J:J").Select
Selection.Insert Shift:=xlToRight
Range("G2").Select
ActiveCell.FormulaR1C1 = "1"
Range("G3").Select
ActiveWindow.WindowState = xlMaximized
Range("G2").Select
Selection.Copy
Range("I2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Range("I2").Select
ActiveWindow.SmallScroll ToRight:=4
Range("K1").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveSheet.Range("A:Z").AutoFilter Field:=11, Criteria1:= _
"INATIVE"
Rows("5:5").Select
Range("D5").Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Range("K1").Select
ActiveSheet.Range("A:Z").AutoFilter Field:=11
Range("L2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],'DL List'!RC[-11]:R[31]C[-10],2,0)"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L5885")
Range("L2:L5885").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("L2").Select
Application.CutCopyMode = False
ActiveSheet.Range("A:Z").AutoFilter Field:=11, Criteria1:="MOH"
ActiveSheet.Range("A:Z").AutoFilter Field:=12, Criteria1:="#N/A"
Range("L14").Select
ActiveCell.FormulaR1C1 = "IDL"
Range("L18").Select
ActiveWindow.WindowState = xlMaximized
Range("L14").Select
Selection.Copy
Range("L18").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
ActiveSheet.Range("A:Z").AutoFilter Field:=12
Application.CutCopyMode = False
Range("K14").Select
ActiveSheet.Range("A:Z").AutoFilter Field:=11, Criteria1:="G&A"
ActiveSheet.Range("A:Z").AutoFilter Field:=12
Range("L29").Select
ActiveCell.FormulaR1C1 = "IDL"
Range("L29").Select
Selection.Copy
Range("L140").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Range("L29").Select
Application.CutCopyMode = False
ActiveSheet.Range("A:Z").AutoFilter Field:=11, Criteria1:="DL"
ActiveSheet.Range("A:Z").AutoFilter Field:=12, Criteria1:="#N/A"
Range("L22").Select
ActiveCell.FormulaR1C1 = "DL"
Range("L24").Select
ActiveWindow.WindowState = xlMaximized
Range("L22").Select
Selection.Copy
Range("L24").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
ActiveSheet.Range("A:Z").AutoFilter Field:=12
Range("L4").Select
Application.CutCopyMode = False
ActiveSheet.Range("A:Z").AutoFilter Field:=11, Criteria1:="IDL"
ActiveSheet.Range("A:Z").AutoFilter Field:=12, Criteria1:="#N/A"
Range("L7").Select
ActiveCell.FormulaR1C1 = "IDL"
Range("L28").Select
ActiveWindow.WindowState = xlMaximized
Range("L7").Select
Selection.Copy
Range("L28").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
ActiveSheet.Range("A:Z").AutoFilter Field:=12
ActiveSheet.Range("A:Z").AutoFilter Field:=11
Application.CutCopyMode = False
Range("L19").Select
ActiveWindow.SmallScroll Down:=-45
ActiveSheet.Range("A:Z").AutoFilter Field:=12
End Sub
Bookmarks