Actually I will post the whole code for better understanding hopefully it will help to clarify my issue a little better...
Option Explicit
Sub TrainingHoursMacro()
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
Dim wbRegularesBruto As Workbook, wsMovimentacao As Worksheet, wsDemitidos As Worksheet
Dim wbTemporariosBruto As Workbook, wsTemporariosAtivos As Worksheet, wsJAAtivos As Worksheet, wsAprendizesFit As Worksheet
Dim wbPresenceSystem As Workbook, wsTPCC As Worksheet
Set wbTHMacro = Workbooks("Training Hours Macro.xlsm")
Set wsRegulares = wbTHMacro.Sheets("Regulares")
wsRegulares.Cells.ClearContents
Set wbRegularesBruto = Workbooks.Open(Filename:="H:\BX-HR\BX-INDUSTRIAL RELATIONS\HR REPRESENTATIVES\PRIVATE\HRSSC\Brazil\Training Hours Macro\Regulares Bruto.xls")
If Not wbRegularesBruto Is Nothing Then
Set wsSheet = wbRegularesBruto.Sheets("Movimentacao")
wsSheet.Cells.Copy wsRegulares.Range("A1")
Set wsSheet = wbRegularesBruto.Sheets("Demitidos")
Set wsRegularesDemitidos = wbTHMacro.Sheets("Regulares Demitidos")
wsSheet.Cells.Copy wsRegularesDemitidos.Range("A1")
wbRegularesBruto.Close False
Else
Exit Sub
End If
Set wbTemporariosBruto = Workbooks.Open(Filename:="H:\BX-HR\BX-INDUSTRIAL RELATIONS\HR REPRESENTATIVES\PRIVATE\HRSSC\Brazil\Training Hours Macro\Temporarios Bruto.xlsx")
If Not wbTemporariosBruto Is Nothing Then
Set wsSheet = wbTemporariosBruto.Sheets("Temporarios Ativos")
Set wsTempActivos = wbTHMacro.Sheets("Temp Activos")
wsSheet.Cells.Copy wsTempActivos.Range("A1")
Set wsSheet = wbTemporariosBruto.Sheets("JA Ativos")
Set wsTempJA = wbTHMacro.Sheets("Temp JA")
wsSheet.Cells.Copy wsTempJA.Range("A1")
Set wsSheet = wbTemporariosBruto.Sheets("Aprendizes FIT")
Set wsTempFit = wbTHMacro.Sheets("Temp Fit")
wsSheet.Cells.Copy wsTempFit.Range("A1")
Set wsSheet = wbTemporariosBruto.Sheets("Demitidos")
Set wsTempDemitidos = wbTHMacro.Sheets("Temp Demitidos")
wsSheet.Cells.Copy wsTempDemitidos.Range("A1")
wbTemporariosBruto.Close False
Else
Exit Sub
End If
Set wbPresenceSystem = Workbooks.Open(Filename:="H:\BX-HR\BX-INDUSTRIAL RELATIONS\HR REPRESENTATIVES\PRIVATE\HRSSC\Brazil\Training Hours Macro\Presence System Bruto.xls")
If Not wbPresenceSystem Is Nothing Then
Set wsSheet = wsTPCC.Sheets("TPCC")
Set wsPresenceSystem = wbTHMacro.Sheets("PS")
wsSheet.Cells.Copy wsTempActivos.Range("A1")
End Sub
Bookmarks