title: Excel VBA: Loop through cells and copy values to another workbook
body: <p>I already spent hours on this problem, but I didn't succeed in finding a working solution.</p>
  
  <p>Here is my <strong>problem description</strong>:</p>
  
  <p>I want to loop through a certain range of cells in one workbook and copy values to another workbook. Depending on the current column in the first workbook, I copy the values into a different sheet in the second workbook.
  When I execute my code, I always get the <code>runtime error 439: object does not support this method or property</code>.</p>
  
  <p>My <strong>code</strong> looks more or less like this:</p>
  
  <pre><code>Sub trial()
  
  Dim Group As Range
  Dim Mat As Range
  Dim CurCell_1 As Range
  Dim CurCell_2 As Range
  
  Application.ScreenUpdating = False
  
  Set CurCell_1 = Range("B3") 'starting point in wb 1
  
  For Each Group in Workbooks("My_WB_1").Worksheets("My_Sheet").Range("B4:P4")
      Set CurCell_2 = Range("B4") 'starting point in wb 2
      For Each Mat in Workbooks("My_WB_1").Worksheets("My_Sheet").Range("A5:A29")
          Set CurCell_1 = Cells(Mat.Row, Group.Column) 'Set current cell in the loop
          If Not IsEmpty(CurCell_1)
              Workbooks("My_WB_2").Worksheets(CStr(Group.Value)).CurCell_2.Value = Workbooks("My_WB_1").Worksheets("My_Sheet").CurCell_1.Value 'Here it break with runtime error '438 object does not support this method or property
              CurCell_2 = CurCell_2.Offset(1,0) 'Move one cell down
          End If
      Next
  Next
  
  Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  
  <p>I've done extensive research and I know how to copy values from one workbook to another if you're using explicit names for your objects (sheets &amp; ranges), but I don't know why it does not work like I implemented it using variables.
  I also searched on stackoverlow and -obviously- Google, but I didn't find a similar problem which would answer my question.</p>
  
  <p>So my <strong>question</strong> is:
  Could you tell me where the error in my code is or if there is another easier way to accomplish the same using a different way?</p>
  
  <p>This is my first question here, so I hope everything is fine with the format of my code, the question asked and the information provided. Otherwise let me know.</p>