title: Why is this error Method sheets of Object '_workbook' failed occuring in my macro?
body: <p>I started learning VBA for excel 2007. Can anyone help why this error is happening while execution:</p>
  
  <p>The code is </p>
  
  <pre><code>Public Sub LastVariable_Check()
      'Check if Last Variable is of latest month sales
  
      'lastvariable  = lv
  
      lv = wkbOut.Sheets("Sheet1").Range("B1",Range("B1").End(xlToRight)).End(xlToRight).Text
      If "0" &amp; Mid(lv, InStr(lv, "Month/") + 6, 1) = strmth _
      And Mid(lv, InStr(lv, "Month/") + 8, 4) = strYear Then
          Set wkbRaw = Workbooks.Open(strInputQCPath &amp; "Errorlog.xlsx")
  
          wkbRaw.Sheets("Sheet1").Range("A1").Offset(i, 2).Value = "Correct"
          wkbRaw.SaveAs Filename:=strInputQCPath &amp; "Errorlog.xlsx"
          wkbRaw.Close
      Else
          Set wkbRaw = Workbooks.Open(strInputQCPath &amp; "Errorlog.xlsx")
  
          wkbRaw.Sheets("Sheet1").Range("A1").Offset(i, 2).Value = "Incorrect"
          wkbRaw.SaveAs Filename:=strInputQCPath &amp; "Errorlog.xlsx"
          wkbRaw.Close
      End If 
  End Sub
  </code></pre>
  
  <p>Please help<br>
  Thanks!</p>