title: Run Time Error "424": Object Required when copying data from one workbook to an active one
body: <p>Good Evening.</p>
  
  <p>I have been working on the following project, which is generating several 424 Run Time Errors.</p>
  
  <p>The following public sub is declared in ThisWorkbook:</p>
  
  <pre><code>Public Sub Workbook_Open()
  
  Dim rolandPath As String 'Declares global string variable rolandFile for RoLanD's filepath
  Dim rolandSource As Workbook ' declares global workbook variable rolandSource for RoLanD listed in rolandPath
  Dim destinationWorkbook As Workbook 'declares global workbook variable destinationWorkbook for Extract Tool
  Dim storeID As Integer ' Declares global integer variable storeID for Store's 4 digit ID
  Dim tFocus As Long 'Declares global long variable tFocus for current Tab in focus
  Dim cFocus As Long 'Declares global long variable cFocus for current Column in focus
  Dim rFocus As Long 'Declares global long variable rFocus for current Row in focus
  Dim rRecord As Long 'Declares global long variable rRecord for current Row being recorded to
  
  Call DataConnect
  
  End Sub
  </code></pre>
  
  <p>The remainder of this code is in Module1:</p>
  
  <pre><code>Sub DataConnect()
  MsgBox ("Please select your RoLanD file. If you are asked to enter your password, please do this. If you select Cancel, you may need to exit and restart this application.") 'Explains to the user what to do next.
  FilePath = Application.GetOpenFilename 'Opens dialogue for user to select RoLanD file
      If FilePath &lt;&gt; "" Then 'Checks that the filepath is completed
         rolandPath = FilePath 'Stores the filepath for RoLanD into the variable rolandFile
      End If
  storeID = InputBox("Please enter your Store's four digit ID (EG: 0123). If you enter this incorrectly, this may result in your colleagues records being incorrectly applied", "Enter Store ID") ' Prompts user to enter store ID, then stores it as integer storeID
  MsgBox ("Thank you. Your current RoLanD data will now be copied. This will leave your data intact in RoLanD, so please do not be concerned. Please select OK to continue.") 'Gives a message to reassure user.
  
  cFocus = "Q" 'Sets the Column in focus to Column Q
  rFocus = 5 'Sets the Row in focus to the fifth one
  rRecord = 1 'Sets the row the record is being recorded to as the first one
  tFocus = 1 'Sets the Tab in focus to the first one
  
  Set rolandSource = Workbooks.Open(rolandPath)
  
  On Error Resume Next ' tells DB to move on when error is reached
  Do
      Call tInFocus
      tFocus = tFocus + 1 'Adds tab (worksheet) in focus up one
  Loop Until Err.Number &lt;&gt; 0 'breaks when no more worksheets available
  
  MsgBox ("Data is fully copied.")
  End Sub
  
  Sub tInFocus()
  cFocus = "Q" 'Sets the Column in focus to Column Q
  rFocus = 5 'Sets the Row in focus to the fifth one
  If rolandSource.Worksheets(tFocus).Range("Q4").Value = "" Then Exit Sub 'Ends subroutine if Q4 is empty, which means no data on this RoLanD tab
  Do
      Do
          ThisWorkbook.Worksheets("1").Range("A" &amp; rRecord).Value = rolandSource.Sheets(tFocus).Range("B" &amp; rFocus) 'Copies employee number in focus to destination
          ThisWorkbook.Worksheets("1").Range("B" &amp; rRecord).Value = rolandSource.Worksheets(tFocus).Range(cFocus &amp; "4") ' Copies learning title in focus to destination
          ThisWorkbook.Wksheets("1").Range("C" &amp; rRecord).Value = rolandSource.Worksheets(tFocus).Range(cFocus &amp; rFocus) 'Copies learning completion date in focus to destination
          ThisWorkbook.Worksheets("1").Range("D" &amp; rRecord).Value = storeID 'Copies store ID to row in focus
          rRecord = rRecord + 1 'Moves line being recorded to on one
          cFocus = Chr(Asc(cFocus) + 1) 'Moves column in focus up one
      Loop Until rolandSource.Worksheets(tFocus).Range(cFocus &amp; 4) = "" 'Breaks loop when end column reached
      rFocus = rFocus + 1 'Moves row in focus up one
      cFocus = "Q" 'Resets cFocus to Column Q
  Loop Until rolandSource.Worksheets(tFocus).Range(B &amp; rFocus) = "" 'Breaks loop when end row reached
  
  End Sub
  </code></pre>
  
  <p>There are two issues I am having; the first is the <strong>Loop Until Err.Number &lt;> 0</strong> is ending after the first instance. This should end the loop when tFocus is at a value where no worksheet exists.</p>
  
  <p>The second, and larger issue, is that the following lines are generating <strong>Run Time Error "424": Object Required</strong> error messages in the debug window:</p>
  
  <p><strong>If rolandSource.Worksheets(tFocus).Range("Q4").Value = "" Then Exit Sub</strong></p>
  
  <p><strong>ThisWorkbook.Worksheets("1").Range("A" &amp; rRecord).Value = rolandSource.Sheets(tFocus).Range("B" &amp; rFocus) 'Copies employee number in focus to destination</strong></p>
  
  <p><strong>ThisWorkbook.Worksheets("1").Range("B" &amp; rRecord).Value = rolandSource.Worksheets(tFocus).Range(cFocus &amp; "4") ' Copies learning title in focus to destination</strong></p>
  
  <p><strong>ThisWorkbook.Wksheets("1").Range("C" &amp; rRecord).Value = rolandSource.Worksheets(tFocus).Range(cFocus &amp; rFocus) 'Copies learning completion date in focus to destination</strong></p>
  
  <p><strong>ThisWorkbook.Worksheets("1").Range("D" &amp; rRecord).Value = storeID 'Copies store ID to row in focus</strong></p>
  
  <p><strong>Loop Until rolandSource.Worksheets(tFocus).Range(cFocus &amp; 4) = "" 'Breaks loop when end column reached</strong></p>
  
  <p><strong>Loop Until rolandSource.Worksheets(tFocus).Range(B &amp; rFocus) = "" 'Breaks loop when end row reached</strong></p>
  
  <p>I have read several articles and tried varying approaches, including changing the lines that copy data to the following:</p>
  
  <pre><code>rolandSource.Activate
  rolandSource.Worksheet(tFocus).Cell("B" &amp; rFocus).Copy
  ThisWorkbook.Activate
  ThisWorkbook.Worksheet(1).Call("A" &amp; rRecord).Paste
  </code></pre>
  
  <p>This produced the same results.</p>
  
  <p>Any ideas or support would be greatly appreciated. I am returning to coding after a loooong break, and know I am probably doing something really silly, but can't figure out what!</p>
  
  <p>Thanks in anticipation, Dan</p>