title: My VBA behaves differently when assigned to a button
body: <p>I have set up a Quality Check sheet which needs to store results in a separate sheet called 'Data' as a row of data, and save an archived version of the full Check Sheet in a separate workbook.
  I'm quite a novice on VBA but have managed to get what I need working. My problem comes when I assign the macro to a button which is contained on my check sheet. If I press the button it copies the wrong sheet over and basically does not do what it does when I run the macro manually. Can anyone suggest anything please?</p>
  
  <p>Thanks</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>Sub SaveForm()
  
  ' SaveForm Macro
  ' Saves form data to the Data Sheet
  
  'Checks for completion of mandatory fields
  
  If IsEmpty(Range("b3").Value) = True Then
    MsgBox "Please complete 'Agent Name' before saving"
    Exit Sub
  
  ElseIf IsEmpty(Range("b4").Value) = True Then
    MsgBox "Please complete 'Call ID' before saving"
    Exit Sub
  
  ElseIf IsEmpty(Range("b5").Value) = True Then
    MsgBox "Please complete 'Call Length' before saving"
    Exit Sub
  
  ElseIf IsEmpty(Range("D3").Value) = True Then
    MsgBox "Please complete 'Business Name' before saving"
    Exit Sub
  
  ElseIf IsEmpty(Range("D4").Value) = True Then
    MsgBox "Please complete 'Date of Call' before saving"
    Exit Sub
  
  ElseIf IsEmpty(Range("D5").Value) = True Then
    MsgBox "Please complete 'Time of Call' before saving"
    Exit Sub
  
  ElseIf IsEmpty(Range("b7").Value) = True Then
    MsgBox "Please complete 'Assessor Name' before saving"
    Exit Sub
  
  ElseIf IsEmpty(Range("b8").Value) = True Then
    MsgBox "Please complete 'Date of Assessment' before saving"
    Exit Sub
  
  
  End If
  
  'Copies a range contained within the "Checksheet" and pastes
  'it into the next available row on the "Data" sheet
  
  'The reason it is in a straight row as opposed to sporadic cell
  'references is because I have set the sheet up this way for simplicity
  
  Range("M14:BP14").Copy
  
  Sheets("Data").Range("A" &amp; Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  ActiveWindow.ScrollRow = 1
  Workbooks("Call Feedback Form V0.42.xlsm").Sheets("Checksheet").Activate
  
  Call CopyRenameWorksheet
  
  Workbooks("Call Feedback Form V0.42.xlsm").Sheets("Checksheet").Activate
  
  End Sub
  </code></pre>
  
  <p>.</p>
  
  <pre><code>Sub CopyRenameWorksheet()
  
  'This renames the worksheet based on cell references and archives to another workbook
  
  Dim ws As Worksheet
  Set wh = Worksheets(ActiveSheet.Name)
  ActiveSheet.Copy After:=Worksheets(Sheets.Count)
  If wh.Range("B3").Value &lt;&gt; "" Then
  ActiveSheet.Name = wh.Range("B3").Value &amp; " " &amp; Format(wh.Range("D4").Value, ("yymmdd")) &amp; " " &amp; wh.Range("B4").Value
  ActiveSheet.Move After:=Workbooks( _
  "Archived Quality Forms.xlsx").Sheets(1)
  
  End If
  </code></pre>