title: Change Worksheet after personalized right click option added
body: <p>I have the following code that works as expected:</p>
  <pre><code>Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Dim cmdBtn As CommandBarButton
    Dim currentUPC As String
    Dim currentArticle As String
  
    
    Set cmdBtn = Application.CommandBars(&quot;Cell&quot;).FindControl(, , &quot;testBt&quot;)
    If Intersect(Target, Range(&quot;C21:C42&quot;)) Is Nothing Then
      If Not cmdBtn Is Nothing Then cmdBtn.Delete
      Exit Sub
    End If
      
      If Not cmdBtn Is Nothing Then Exit Sub
      Set cmdBtn = Application.CommandBars(&quot;Cell&quot;).Controls.Add(Temporary:=True)
      
      currentUPC = ActiveCell.Value
      currentArticle = ActiveCell.Offset(0, 1).Value
      
      With cmdBtn
          .Tag = &quot;testBt&quot;
          .Caption = &quot;Goto UPC&quot;
          .Style = msoButtonCaption
          .OnAction = &quot;=gotoUPC(&quot; &amp; currentUPC &amp; &quot;)&quot;
      End With
     
  End Sub
  </code></pre>
  <p>But the macro it runs is not quite working as planned:</p>
  <pre><code>Sub gotoUPC(currentUPC As String)
     
      Sheets(&quot;UPC Summary&quot;).Range(&quot;A21&quot;).Value = currentUPC
      Worksheets(&quot;UPC Summary&quot;).Activate
     
  End Sub
  </code></pre>
  <p>The value in Range A21 updates correctly but it will not activate the worksheet as required.</p>
  <p>Any additional thoughts on my method of passing the parameter appreciated @FaneDuru</p>
  <p>Any thoughts appreciated, many thanks, Alan.</p>