title: How do I return the name of sheet with a variable on it in a cell?
body: <p>I am trying to have a cell on sheet 1 return the name of the sheet the variables 'r1' (on sheet2) or 'r2' (on sheet3) are referenced from, if they meet qualifications. What I currently have is:</p>
  
  <pre><code>Public Function whichsheet(r1 As Range, r2 As Range) As String
  
  
  If Application.Sum(r1) &gt; 0 Then
      whichsheet = whichsheet &amp; Application.Caller.Worksheet.Name
  
  End If
  
  If Application.Sum(r2) &gt; 0 Then
      whichsheet = whichsheet &amp; Application.Caller.Worksheet.Name
  
  End If
  
  End Function
  </code></pre>
  
  <p>Where  Application.Caller.Worksheet.Name is currently a placeholder that pulls the name of the first sheet, "sheet1" rather than "sheet1" and/or "sheet2".</p>