What's the best way to hide wkb2? This code is ending up with curser in that workbook on top. I want it to be in background (not visible to user)
Sub ImportNotes()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Set wkb2 = Workbooks.Open("\\ccx.carecentrix.com\Shares\Teams\CSC\Staffing\Confidential\MSOC\Notes_donotuse.xlsx")
ThisWorkbook.Activate
Set wsnotes = wkb2.Sheets("Sheet1")
lrnotes = wsnotes.Cells(wsnotes.Rows.Count, "A").End(xlUp).Offset(1).Row
lrsor = wssor.Cells(wssor.Rows.Count, "B").End(xlUp).Row
wssor.Range("W2:W" & lrsor).Formula = "=VLOOKUP(E2,'[Notes_donotuse.xlsx]Sheet1'!$A:$E,2,0)"
wssor.Range("X2:X" & lrsor).Formula = "=VLOOKUP(E2,'[Notes_donotuse.xlsx]Sheet1'!$A:$E,3,0)"
wssor.Range("Y2:Y" & lrsor).Formula = "=VLOOKUP(E2,'[Notes_donotuse.xlsx]Sheet1'!$A:$E,4,0)"
wssor.Range("Z2:Z" & lrsor).Formula = "=VLOOKUP(E2,'[Notes_donotuse.xlsx]Sheet1'!$A:$E,5,0)"
Application.Calculation = xlCalculationAutomatic
wssor.Range("W2:Z" & lrsor).SpecialCells(xlCellTypeVisible).Copy
wssor.Range("W2").PasteSpecial xlPasteValues
wssor.Range("Y2:Y" & lrsor).NumberFormat = "m/d/yyyy"
End Sub
Sub ImportNotes()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Set wkb2 = Workbooks.Open("\\ccx.carecentrix.com\Shares\Teams\CSC\Staffing\Confidential\MSOC\Notes_donotuse.xlsx")
ThisWorkbook.Activate
Set wsnotes = wkb2.Sheets("Sheet1")
lrnotes = wsnotes.Cells(wsnotes.Rows.Count, "A").End(xlUp).Offset(1).Row
lrsor = wssor.Cells(wssor.Rows.Count, "B").End(xlUp).Row
wssor.Range("W2:W" & lrsor).Formula = "=VLOOKUP(E2,'[Notes_donotuse.xlsx]Sheet1'!$A:$E,2,0)"
wssor.Range("X2:X" & lrsor).Formula = "=VLOOKUP(E2,'[Notes_donotuse.xlsx]Sheet1'!$A:$E,3,0)"
wssor.Range("Y2:Y" & lrsor).Formula = "=VLOOKUP(E2,'[Notes_donotuse.xlsx]Sheet1'!$A:$E,4,0)"
wssor.Range("Z2:Z" & lrsor).Formula = "=VLOOKUP(E2,'[Notes_donotuse.xlsx]Sheet1'!$A:$E,5,0)"
Application.Calculation = xlCalculationAutomatic
wssor.Range("W2:Z" & lrsor).SpecialCells(xlCellTypeVisible).Copy
wssor.Range("W2").PasteSpecial xlPasteValues
wssor.Range("Y2:Y" & lrsor).NumberFormat = "m/d/yyyy"
End Sub