Need help to correct my code. My code while closing the excel checks for if a particular cell have a defined value. "Refer Attached GL Exposure Sheet" then it checks for the worksheet. "GL Exposure Sheet". If the sheet is not attached it gives a pop up message.
My problem is even if the cell is blank the pop up message is still displayed which i dont want.
Current code is
Private Sub Workbook_BeforeClose(Cancel As Boolean) 'Dim wsSheet As Worksheet On Error Resume Next 'Set wsSheet = Sheets("GL Exposures Sheet") 'On Error GoTo 0 If Sheets("GL").Range("C42").Value = "Refer GL Exposures Sheet" And Worksheets("GL Exposures Sheet") Is Nothing Then MsgBox "GL Exposures Sheet is Missing" 'ActiveWorkbook.Activate Else End If
It will be great help if anyone can help me out.