title: I'm getting an 'object required' error when calling a vba function
body: <p>I'm getting a 424 &quot;Object Required&quot; when calling a vba function.  The function parameter requires a range to change the name of the worksheet tab to be the same as a cell value.</p>
  <p>Here is the code:</p>
  <pre><code>Dim new_wb As Workbook
  Dim act_wb As Workbook
  Dim stu_name As Object
  Dim lastRow As Long
  Dim currCol As Long
  Dim nameRange As Range
  Set act_wb = ActiveWorkbook
  currCol = ActiveCell.Column
  lastRow = Cells(Rows.Count, 1).End(xlUp).Row
  Set nameRange = Worksheets(1).Range(&quot;A4&quot;)
  
  
  'begin vba code
  ActiveWorkbook.Sheets(1).copy
  Worksheet_Change (nameRange) 'error occurs here.  
  </code></pre>
  <p>Here is the function signature of the function being called:</p>
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  </code></pre>
  <p>If I remove the 'Set' keyword for nameRange, I get the following error</p>
  <p><a href="https://i.stack.imgur.com/PWVtE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PWVtE.png" alt="errormessage" /></a></p>