title: Excel macro copy function
body: <p>I know this question has already been asked but I would like to understand what I'm doing wrong</p>
  
  <p>I just want to copy a cell to another cell in a different worksheet. The copied cell depend on the row where is located the button.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Option Explicit
  
  Sub CreateButtons()
  
      Dim i As Long
      Dim shp As Object
      Dim dblLeft As Double
      Dim dblTop As Double
      Dim dblWidth As Double
      Dim dblHeight As Double
  
      With Sheets("SALES UNFULFILLED")
          dblLeft = .Columns("AZ:AZ").Left      'All buttons have same Left position
          dblWidth = .Columns("AZ:AZ").Width    'All buttons have same Width
          For i = 2 To 200                     'Starts on row 2 and finishes row 20
              dblHeight = .Rows(i).Height     'Set Height to height of row
              dblTop = .Rows(i).Top           'Set Top top of row
              Set shp = .Buttons.Add(dblLeft, dblTop, dblWidth, dblHeight)
              shp.OnAction = "IdentifySelected"
              shp.Characters.Text = "Invoice"
          Next i
      End With  
  End Sub
  
  
  Sub IdentifySelected()
      'NOTE: The button will always be on the active sheet
      Dim strButtonName
      Dim lngRow As Long
  
      strButtonName = ActiveSheet.Shapes(Application.Caller).Name
      lngRow = ActiveSheet.Shapes(strButtonName).TopLeftCell.Row
      'MsgBox "Button is on row " &amp; lngRow
      Worksheets("invoice").Range(Cells(5, 3)).Value = Worksheets("SALES UNFULFILLED").Range(Cells(lngRow, 4)).Value
  End Sub
  </code></pre>
  
  <p>I keep getting an error 1004  on this line of code but I don't understand why
  <code>Worksheets("invoice").Range(Cells(5, 3)).Value = Worksheets("SALES UNFULFILLED").Range(Cells(lngRow, 4)).Value</code></p>
  
  <p>I tried to change "Value" by "Select" but no chance</p>