title: Manually Set Application.Caller in Excel VBA
body: <p>I've been trying to use a button1 to activate button2. The problem is that button2 has to use application.caller which defaults to the button origanally pressed (button1). </p>
  
  <p>How do I set a new value for application.caller?</p>
  
  <p>Here's the sample code: </p>
  
  <p>Button1:</p>
  
  <pre><code>Sub ShowAttack()
  'Change the color of the other buttons to the background color.
  
  'Pressed button to lighter color.
  ActiveSheet.Shapes("AttackButton").Fill.ForeColor.RGB = 14277081
  
  'Other buttons to darker colors.
  ActiveSheet.Shapes("DefenseButton").Fill.ForeColor.RGB = 12566463
  ActiveSheet.Shapes("SpellButton").Fill.ForeColor.RGB = 12566463
  
  'Toggle Appropriate Cells to unhide
  Dim button As Shape
  Set button = ActiveSheet.Shapes("AttackButton")
  rw = button.TopLeftCell.Row
  Rows((rw + 4) &amp; ":" &amp; (rw + 74)).EntireRow.Hidden = False
  
  'Hide appropriate cells within shown section
  
  Set Application.Caller = ActiveSheet.Buttons("WeaponDetailsButton1").Name
  Application.Run ActiveSheet.Buttons("WeaponDetailsButton1").OnAction
  
  Range("AT51").Select
  
  End Sub
  </code></pre>
  
  <p>Button 2: </p>
  
  <pre><code>Sub HideWeaponDetails()
      Dim b As Object, cs As Integer, rw As Integer
      Dim sel01 As Integer, sel02 As Integer
      Set b = ActiveSheet.Buttons(Application.Caller)
      With b.TopLeftCell
          cs = .Column
          rw = .Row
      End With
  
  sel01 = rw + 4
  sel02 = rw + 14
  
  Rows(sel01 &amp; ":" &amp; sel02).Select
  If Selection.EntireRow.Hidden = False Then
      Selection.EntireRow.Hidden = True
  Else
      Selection.EntireRow.Hidden = False
  End If
  
  Range("A" &amp; rw - 4).Select
      ActiveSheet.Buttons(Application.Caller).Name = "WeaponDetailsButton" &amp; Selection(1).Value
  Range("AV47").Value = ActiveSheet.Buttons(Application.Caller).Name
  
  Range("A1").ClearOutline
  </code></pre>
  
  <p>End Sub</p>