title: Building a function for excel that returns a string
body: <p>I'm practicing building functions that are used as formula's in cells and seem to have hit a snag.   The code below works as long as it is not returning a string while being used in a cell.  This code works perfectly for integers and even works with strings when I've coded a sub to use the function.  I can't seem to figure out why when i use it in a formula in a cell it returns </p>
  
  <pre><code>Function bIsBlank(x As String) As String
  
  Dim y As String
  
  If x = "" Then  'check to see if it is blank
      Exit Function
  Else 
      y = Evaluate(x) 'solve the formula that is pulled in
  
      If y = "0" Then 'check to see if formula equals zero
          y = ""      'set to nothing if it is zero
      End If
  End If
  
      'below is my attempt to fix it by adding quotes on either side of the string
      'this did not work
      y = Chr(34) &amp; y &amp; Chr(34)
  
  'this seems to solve for a sub but not a formula in a cell for strings
  bIsBlank = y
  
  End Function
  </code></pre>
  
  <hr>
  
  <p>The issue is that i didn't need to use the evaluate function.   The formula i was pulling in was already solved.   So say i had a vlookup that solved for "A".  In the code X = "A" not the string vlookup(a1,a5:b10,2,0) as I originally expected</p>