title: VBA Excel 2010 - Runtime error '1004' Application-defined or object-deined error
body: <p><strong>EDIT:</strong></p>
  
  <p>So, it appears my excel document contain my code has corrupted thus causes the quite unusual problem, I thank you all for the help you have given. This has been resolved by moving all macros and sheets into a new excel document</p>
  
  <p>The code below will get the error message "Runtime error '1004' Application-defined or object-deined error" at <code>ActiveCell.Offset(1, 0).Select</code> at the bottom but when it is run the code also doesnt run the <code>[C7].Select</code> part either (but there is no error message at this point)</p>
  
  <p>I have tried using, <code>Range("C7").select</code> and <code>Cells(7,3).select</code> which also dont work. I have also tried <code>Application.Wait</code> to see if the macro may have been too fast however this also doesnt resolve the issue, I have removed the <code>Application.ScreenUpdating = False</code> and again this doesnt work.</p>
  
  <p>I have tried this macro on 4 different PCs and 2 different versions of excel and all have the same issue.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Just to clear things up as I think my explination above may be a bit unclear</p>
  
  <p>The problem is currently with this section of code</p>
  
  <pre><code>[C7].Select
  'Do Until ActiveCell.Row &gt;= Finalrow
  'drop out of loop if no more dates detected in row 3
  Do Until sName = Cells(ActiveCell.Row, 1).Value
  ActiveCell.Offset(1, 0).Select
  Loop
  </code></pre>
  
  <p>What happens when I run the code to this part of the code is the error message above will appear at <code>ActiveCell.Offset(1, 0).Select</code> this line, however <code>[C7].Select</code> also does not select cell C7 (it remains at the cell that was already selected). </p>
  
  <p>What is supposed to happen is that it runs down the cells in column C looking at column A until it reachs the persons name (defined by <code>sName</code>), once it gets to that is will then run the rest of the code (that I havent posted at I cant get further than this point, I can post the whole thing if requested)</p>
  
  <hr>
  
  <pre><code>Option Compare Text
  Public sLeave As Integer, iAnnualLeave As Integer, sLeaveType As String
  
  Sub LeaveChecker()
  
  Dim iAnnualLeave As Integer
  
  bTrackingLeave = False
  bReachedEndOfChart = False
  bStartDateFound = False
  
  'Set Color with If Statement
  
  
  
  sTypeOfLeave = [D12].Value
  
  If sTypeOfLeave = "Annual Leave" Then
  sLeaveType = "AL"
  ElseIf sTypeOfLeave = "Flexi Leave" Then
  sLeaveType = "FL"
  sLeaveTypeAmPm = "FL???"
  
  ElseIf sTypeOfLeave = "Special Leave" Then
  sLeaveType = "SpL"
  ElseIf sTypeOfLeave = "Study Leave" Then
  sLeaveType = "StL"
  ElseIf sTypeOfLeave = "Meeting/Traning" Then
  sLeaveType = "M/T"
  End If
  
  'Check to see if type of leave is populated
  If sTypeOfLeave = "" Then
  MsgBox ("Please Populate Type Of Leave")
  End If
  
  
  
  
  Application.ScreenUpdating = False
  
  'Find last sheet name
  Set ws = Sheets(Sheets.Count)
  sLastSheet = ws.Name
  
  sName = [M3].Value
  
  If sName = "" Then
  MsgBox ("Please Enter A Staff Members Name")
  Exit Sub
  End If
  
  Sheets(ActiveSheet.Index + 1).Activate
  
  SearchNewSheet:
  
  If ActiveSheet.Name = sLastSheet Then
  bReachedEndOfChart = True
  GoTo LastStage
  End If
  
  Do Until ActiveSheet.Name = sLastSheet 'Main   LOOP~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
  If bReachedEndOfChart = True Then GoTo FinalGather
  
  'Find Person Name
  
  
  [C7].Select
  'Do Until ActiveCell.Row &gt;= Finalrow
  'drop out of loop if no more dates detected in row 3
  Do Until sName = Cells(ActiveCell.Row, 1).Value
  ActiveCell.Offset(1, 0).Select
  Loop
  </code></pre>