title: Returning user-defined types on Excel VBA
body: <p>I've been fiddling with Excel VBA for some time, but I never had any formal training whatsoever. I have the following piece of code on a XLSM module :</p>
  
  <pre><code>Public Type ks_solution
      W As Integer
      NF As String
      ID As Integer
  End Type
  
  Public Sub MySub()
      //does some things
      MyKSSolution = MyFunction(params)
  End Sub
  
  Public Function MyFunction(params) as ks_solution
      //does stuff and returns a ks_solution
  End Function
  </code></pre>
  
  <p>When I try to run the code, VBA compiler returns a "Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions" error.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>--Yuri</p>